I have a number in base 10. Is there anyway to translate it to a base 62?
Example:
echo convert(12324324); // returns Yg3 (fantasy example here)
A simpler (and possibly faster) implementation that does not use pow nor log:
pow
log
function base62($num) { $index = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $res = ''; do { $res = $index[$num % 62] . $res; $num = intval($num / 62); } while ($num); return $res; }