Skip to content

Instantly share code, notes, and snippets.

@ph3nx
Last active July 27, 2016 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ph3nx/5073638 to your computer and use it in GitHub Desktop.
Save ph3nx/5073638 to your computer and use it in GitHub Desktop.
This code snipped shows you how to generate random strings in PHP.
<?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