note 28783 deleted from function.rand by sniper
| From: | sniper@php.net | Date: | Tue, 23 Sep 2003 22:33:27 +0000 |
| Subject: | note 28783 deleted from function.rand by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57002@lists.php.net to get a copy of this message | ||
Note Submitter: scott@suchisthis.com
----
function GenPass($_maxlen) {
$A = "abcdefghijklmnopqrstuvwxyz0123456789";
for ($i=0;$i<=$_maxlen;$i++) {
$code .= $A[rand(0,strlen($A))];
}
return $code;
}
usage:
$my_password = GenPass(5);
print $my_password;
prints out a 5-digit random code.