note 28783 added to function.rand
| From: | scott at suchisthis dot com | Date: | Thu, 23 Jan 2003 19:41:32 +0000 |
| Subject: | note 28783 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42658@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/function.rand.php
http://master.php.net/manage/user-notes.php?action=edit+28783
http://master.php.net/manage/user-notes.php?action=delete+28783
http://master.php.net/manage/user-notes.php?action=reject+28783