Re: srand thought
| From: | Mike Eheler | Date: | Thu, 02 May 2002 22:24:00 +0000 |
| Subject: | Re: srand thought | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95786@lists.php.net to get a copy of this message | ||
Yeah. If I understand correctly, if you do, like:
<?php
$seed = time();
srand($seed);
$var = rand(0,50);
echo "$var\n";
srand($seed);
$var2 = rand(0,50);
echo "$var2\n";
?>
Then, I believe, the theory is that you will get the same "random" number twice.
Mike
Miguel Cruz wrote:
On Thu, 2 May 2002, Gerard Samuel wrote:Quick question. Im using srand to seed array_rand in a script. I read that srand should only be called once per script under the srand manual page. Im using ADODB, and that also uses srand. Now should that warning be a literal warning or should that be 'use srand once per page'??It's probably not worth worrying about unless both calls use the same seed and you are generating one or more random numbers between the two srand() calls that are part of the same sequence as random numbers generated after the second one. miguel