Created
May 21, 2013 12:20
-
-
Save cdaven/5619397 to your computer and use it in GitHub Desktop.
Generate a string of random characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateRandomString($length = 10) | |
{ | |
$alphabet = '0123456789abcdefghijklmnopqrstuvwxyz'; | |
$alphabet_length = strlen($alphabet); | |
$randomChars = array(); | |
for ($i = 0; $i < $length; $i++) | |
{ | |
$randomChars[] = $alphabet[mt_rand(0, $alphabet_length - 1)]; | |
} | |
return join('', $randomChars); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment