- substr: documentation ( source)
- ltrim: documentation ( source)
- floor: documentation ( source)
- pack: documentation ( source)
- str_pad: documentation ( source)
<?php
$str = "Uo9kOMrb8Zfx8cHXT65JPNGYEbiYq90YNImYPdLkOo8w8Y8i8cPrRcD1ScSYEY8YB29ZRsvaQNHfRsuYEY91JaGYB29cTMniNsLkT79v8ZfcOMnpPImYRcywABgokJoH7JCmjZcolhT";
function base62_decode ($data) {
$outstring = '';
$len = strlen($data);
for ($i = 0; $i < $len; $i += 11) {
$chunk = substr($data, $i, 11);
$outlen = floor((strlen($chunk) * 6) / 8);
$y = gmp_strval(gmp_init(ltrim($chunk, '0'), 62), 16);
$pad = str_pad($y, $outlen * 2, '0', STR_PAD_LEFT);
$outstring .= pack('H*', $pad);
}
return $outstring;
}
echo(base62_decode($str));