Last active
July 27, 2016 11:26
-
-
Save ph3nx/5073638 to your computer and use it in GitHub Desktop.
This code snipped shows you how to generate random strings in PHP.
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($length) { | |
$LETTERS = 'abcdefghijklmnopqrstuvwxyz'; | |
$random_string = ''; | |
for ($i=0; $i < $length; $i++) { | |
$random_string = $random_string.$LETTERS[rand(0, strlen($LETTERS)-1)]; | |
} | |
return $random_string; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment