This is not a perfect algorithm, as there will be a slight preference for smaller ID numbers. It assumes the user IDs are spread out fairly evenly, so to speak; if they're not, the distribution may not be good.
Figure out what your alphabet is and put it in a string like $str = '0123456789abcdefghijklmnopqrstuvwxxyzABCDEFGHIJKLMNOPQRSTUVXYZ';
This string has n characters. Now, we will essentially treat the user ID as a base n integer.
For each character, find its index in the string (0-based). Take this index and multiply it with nx, where x is the character position in your original string, starting with 0. Add all of these together, and take the modulo of the sum.
You probably only want to do this for a few characters - once you've read a few characters, the sum becomes quite big, and PHP can't handle it properly unless you resort to using functions suitable for large integer math (you can certainly use GMP and such, but it may not be ideal for your case). If you are using native integers, stop before the maximum possible sum goes beyond 2^31 (nx+nx+1+...+n).
You can use either start from the beginning or going backwards (going backwards corresponds to usual integer notation). One of them may be more suitable, depending on how the ID generation works.