note 63455 added to function.rand
| From: | leetcrew<at>gamesite-cafe" com | Date: | Wed, 22 Mar 2006 17:47:14 +0000 |
| Subject: | note 63455 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-106277@lists.php.net to get a copy of this message | ||
this code is very usefull if you are planning to have a "forgot password" or "lost
password" function on your website.
<?php
function generate($max_char=5)
{
# 61 possible characters
$possible_combinations = array (
'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5',
'6', '7', '8', '9');
$generated_code = $possible_combinations[rand(0,61)];
for ( $i=5; $i<=$max_char; $i++)
{
$generated_code .= $possible_combinations[rand(0,61)];
}
$generated_code .= $possible_combinations[rand(52,61)];
$generated_code .= $possible_combinations[rand(52,61)];
$generated_code .= $possible_combinations[rand(52,61)];
return $generated_code;
}
?>
----
Server IP: 66.163.161.117
Probable Submitter: 58.69.205.80
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- http://master.php.net/note/edit/63455
Del: integrated -- http://master.php.net/note/delete/63455/integrated
Del: useless -- http://master.php.net/note/delete/63455/useless
Del: bad code -- http://master.php.net/note/delete/63455/bad+code
Del: spam -- http://master.php.net/note/delete/63455/spam
Del: non-english -- http://master.php.net/note/delete/63455/non-english
Del: in docs -- http://master.php.net/note/delete/63455/in+docs
Del: other reasons-- http://master.php.net/note/delete/63455
Reject -- http://master.php.net/note/reject/63455
Search -- http://master.php.net/manage/user-notes.php