Skip to content

Instantly share code, notes, and snippets.

@atbradley
Created April 28, 2011 14:20
Show Gist options
  • Save atbradley/946439 to your computer and use it in GitHub Desktop.
Save atbradley/946439 to your computer and use it in GitHub Desktop.
Generate a random-enough string. Maybe useful for passwords or for the encryption seed required in some frameworks' configuration file.
function randstr($len = 8) {
$src = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$src = $src.$src.$src.$src.$src;
return substr(str_shuffle($src), 0, $len);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment