function convert2base ($num, $base
{
$symbols = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/'
if (($base<2) || ($basestrlen$symbols)))
throw new Exception'Base must be between 2 and 'strlen$symbols));
$result = ''
while ($num > 0) {
$result = $symbols$num$base].$result
$num = floor$num$base);
}
return $result
}