Skip to content

Instantly share code, notes, and snippets.

@ph3nx
Last active July 27, 2016 11:26
Show Gist options
  • 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