note 26344 deleted from function.rand by philip
| From: | philip@php.net | Date: | Sun, 08 Dec 2002 20:17:12 +0000 |
| Subject: | note 26344 deleted from function.rand by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40544@lists.php.net to get a copy of this message | ||
If you want to generate a random password, use this code:
srand((double) microtime() * 1000000);
$pwd="";
while (strlen($pwd)<8) {
$r=rand(1, 3);
if ($r==1) {
$rcode=rand(48, 57);
}
if ($r==2) {
$rcode=rand(65, 90);
}
if ($r==3) {
$rcode=rand(97, 122);
}
$pwd.=chr($rcode);
}
echo $pwd;
but make shure to call srand() only _once_.