/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function generatePasswords( $howMany = 10, $length = 6, $allowedChars = NULL ) { if (NULL == $allowedChars) { $allowedChars = 'abcdefghijklmnopqrstuvwxyz0123456789'; } $allowedChars = (string)$allowedChars; $count = 0; while ($count < $howMany) { for ($j = $howMany - $count; $j--;) { $code = ''; for ($i = $length; $i--;) { if ($rand % 2) { $code .= $allowedChars{$rand}; } else { $code .= $allowedCharsUpper{$rand}; } } $pwds[$code] = ''; } } }