Skip to content

Instantly share code, notes, and snippets.

@AlexMcowkin
Created July 13, 2015 15:42
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 AlexMcowkin/edf3bf8efacf76164ff0 to your computer and use it in GitHub Desktop.
Save AlexMcowkin/edf3bf8efacf76164ff0 to your computer and use it in GitHub Desktop.
PHP: генерация строки случайными символами
<?php
private function generateRandomPwd($length = 8)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment