Skip to content

Instantly share code, notes, and snippets.

@jpadilla
Created March 28, 2011 16:01
Show Gist options
  • Save jpadilla/890720 to your computer and use it in GitHub Desktop.
Save jpadilla/890720 to your computer and use it in GitHub Desktop.
function random_alnum($len = 8)
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$str = '';
for ($i=0; $i < $len; $i++)
{
$str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
}
return $str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment