On a platter:
$base_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Can be any string of any length (unique characters work best, of course).
$n_base = strlen($base_str);
$num = (37 * pow($n_base, 3)) + (36 * pow($n_base, 2)) + (35 * pow($n_base, 1)) + (34 * pow($n_base, 0));
// B is the 37th character, A the 36th, z the 35th, and y the 34th, so the result should be BAzy.
$converted = dec2base($num, $n_base, $base_str);
echo 'Base 10: ' . $num . '<br />';
echo 'Base ' . $n_base . ': ' . $converted;
function dec2base($dec, $base, $str)
{
$exp = 0;
while ($dec >= pow($base, $exp)) {
$exp++;
}
for (--$exp, $ret = ''; $exp >= 0; $exp--) {
$pow = pow($base, $exp);
$pos = floor($dec / $pow);
$dec = $dec - ($pos * $pow);
$ret .= $str[$pos];
}
return $ret;
}