You want to convert an integer to another base that uses the full alphabet. Base64 may work, but you get strings that are longer than the original integer, because the base64_encode () function takes a string, not an integer.
My suggestion would be to use the base_convert () function as follows:
$id = 12834233; $hash = base_convert($id, 10, 36);
and vice versa
$hash = '7n2yh' $id = base_convert($hash, 36, 10);
This, however, will only use the lowercase letters az and 0-9. If you want to use all upper and lower case letters, you will need to convert to base 62 (or higher if you use characters). However, for this you will have to write your own code.
Edit : Gordon pointed to this excellent link to base62 encoding in php.
bramp source share