Skip to content

Instantly share code, notes, and snippets.

@charlestati
Created March 23, 2015 06:41
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 charlestati/1c756e3475de37982b1f to your computer and use it in GitHub Desktop.
Save charlestati/1c756e3475de37982b1f to your computer and use it in GitHub Desktop.
Generate a random string
$str = '';
$str_len = 31;
$pool = array_merge(range('A', 'Z'), range('a', 'z'), range(0, 9));
for ($i = 0; $i < $str_len; $i++) {
$str .= $pool[mt_rand(0, count($pool) - 1)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment