note 35826 added to function.rand
| From: | bkreleger at rn2 dot php dot net | Date: | Tue, 16 Sep 2003 07:49:47 +0000 |
| Subject: | note 35826 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56558@lists.php.net to get a copy of this message | ||
Yet another simple number generator. This will create a random number with a length of
'x'.
function NumGen($length)
{
for ($i = 1; $i <= $length; $i++)
{
if ($i == 1)
$randnum = rand(0, 9);
else
$randnum .= rand(0, 9);
}
return $randnum;
}
$password = NumGen(10);
echo $password;
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35826
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35826&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35826&report=yes