Re: problems with mt_rand()
| From: | David Robley | Date: | Thu, 31 Jan 2002 22:30:03 +0000 |
| Subject: | Re: problems with mt_rand() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-83013@lists.php.net to get a copy of this message | ||
In article <GIEIJHHAONJCNECMGNKAMEFDCBAA.bderuyter@mediaone.net>,
bderuyter@mediaone.net says...
> I need to generate a random number (range is not crucial) and I have been
> trying to use mt_rand(). However, I am finding that is generates the same
> value EVERY time. This is true whether I supple a range or not. For
> example, the follow line of code generated 13 EVERY time...
>
> $result = mt_rand(1,15);
> echo $result;
>
> In addition, this line of code generated 1755202938 EVERY time...
>
> $result = mt_rand();
> echo $result;
>
> What am I doing wrong??
>
> - Ben
One usually needs to seed a random generator; looking at the docs I find
mt_srand which is the tool you need.
--
David Robley
Temporary Kiwi!