note 45320 added to function.srand
| From: | no at spam dot com | Date: | Thu, 02 Sep 2004 00:00:00 +0000 |
| Subject: | note 45320 added to function.srand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75915@lists.php.net to get a copy of this message | ||
I simply use this, and it has always worked fine:
function initRand ()
{
static $randCalled = FALSE;
if (!$randCalled)
{
srand((double) microtime() * 1000000);
$randCalled = TRUE;
}
}
function randNum ($low, $high)
{
initRand();
$rNum = rand($low, $high);
return $rNum;
}
----
Manual Page -- http://www.php.net/manual/en/function.srand.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45320
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45320&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45320&report=yes
Search -- http://master.php.net/manage/user-notes.php