Skip to content

Instantly share code, notes, and snippets.

@wilhelm-murdoch
Forked from cdevroe/Create Random Number
Created February 11, 2010 00:16
Show Gist options
  • Save wilhelm-murdoch/301020 to your computer and use it in GitHub Desktop.
Save wilhelm-murdoch/301020 to your computer and use it in GitHub Desktop.
function generate_osid($length)
{
$rand = '';
for($i = 0; $i < $length; $i++)
{
$number = mt_rand(0, 61);
if($number < 10)
{
$rand .= chr($number + 48);
}
elseif($randnum < 36)
{
$rand .= chr($number + 55);
}
else
{
$rand .= chr($number + 61);
}
}
return $rand;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment