Created
February 28, 2020 10:23
-
-
Save Inzman/a5bab79c7257dee00caf447a3c08817b to your computer and use it in GitHub Desktop.
Generate random string
This file contains hidden or 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
// https://stackoverflow.com/questions/4356289/php-random-string-generator | |
function generateRandomString($length = 10) { | |
return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length); | |
} | |
echo generateRandomString(); // OR: generateRandomString(24) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment