Skip to content

Instantly share code, notes, and snippets.

@itspriddle
Created September 17, 2010 22:19
Show Gist options
  • Save itspriddle/585055 to your computer and use it in GitHub Desktop.
Save itspriddle/585055 to your computer and use it in GitHub Desktop.
<?php
function generate_password($length = 10)
{
$password = "";
$letters = array(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B',
'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9'
);
for ($i = 0; $i < $length; $i++)
{
$password .= $letters[array_rand($letters)];
}
return $password;
}
echo generate_password();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment