I played around with it and got it to work by using code from PHP random string generator and Can a seeded shuffle be reversed?
function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
function seeded_shuffle(array &$items, $seed = false) {
    $items = array_values($items);
    mt_srand($seed ? $seed : time());
    for ($i = count($items) - 1; $i > 0; $i--) {
        $j = mt_rand(0, $i);
        list($items[$i], $items[$j]) = array($items[$j], $items[$i]);
    }
}
function seeded_unshuffle(array &$items, $seed) {
    $items = array_values($items);
    mt_srand($seed);
    $indices = [];
    for ($i = count($items) - 1; $i > 0; $i--) {
        $indices[$i] = mt_rand(0, $i);
    }
    foreach (array_reverse($indices, true) as $i => $j) {
        list($items[$i], $items[$j]) = [$items[$j], $items[$i]];
    }
}
using those functions you can do it like this, you need to save the $seed though
//$length is the expected lentgth of the encoded id
function encode_id( $id, $seed, $length = 9) {
    $string = $id . generateRandomString($length - strlen($id));
    $arr = (str_split($string));
    seeded_shuffle($arr, $seed);
    return implode("",$arr);    
}
//$length is the expected lentgth of the original id
function decode_id( $encoded_id, $seed, $length = 6) {
   $arr = str_split($encoded_id);
   seeded_unshuffle( $arr, $seed);
   return substr(implode("", $arr),0,$length);
}
$id =  "123456";
$seed = time();
$encodedId =  encode_id($id,$seed);
echo decode_id($encodedId,$seed); //outputs 123456