Created
June 12, 2015 23:44
-
-
Save MohamedBoualleg/71eb5bb75703505d5f03 to your computer and use it in GitHub Desktop.
php function that generate a random string
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 randomStr($lenght){ | |
$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'; | |
$str = str_shuffle($str); | |
while (strlen($str) < $lenght) { | |
$str = $str.randomStr($lenght - strlen($str)); | |
} | |
return substr($str, strlen($str) - $lenght); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment