Last active
September 6, 2015 21:33
-
-
Save vhdm/1e2159c6336274afbbeb to your computer and use it in GitHub Desktop.
Generate 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
<?php | |
function random_string($len=20){ | |
$randstr = ''; | |
srand((double)microtime()*1000000); | |
for($i=0;$i<$len;$i++){ | |
$n = rand(48,120); | |
while (($n >= 58 && $n <= 64) || ($n >= 91 && $n <= 96)){ | |
$n = rand(48,120); | |
} | |
$randstr .= chr($n); | |
} | |
return $randstr; | |
} | |
echo random_string(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment