note 26344 added to function.rand

From: Date: Sun, 27 Oct 2002 13:29:20 +0000
Subject: note 26344 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-38619@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_. -- http://www.php.net/manual/en/function.rand.php http://master.php.net/manage/user-notes.php?action=edit+26344 http://master.php.net/manage/user-notes.php?action=delete+26344 http://master.php.net/manage/user-notes.php?action=reject+26344

« previous php.notes (#38619) next »