Re: Random Numbers

From: Date: Wed, 29 Nov 2000 17:58:56 +0000
Subject: Re: Random Numbers
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-27849@lists.php.net to get a copy of this message
Jason Murray wrote:
Jason Murray wrote:
Gary,
My problem, when the numbers print they print like this. 703 7031 70310 Does anyone know how to get different random numbers to print on the same page, Without the above happening?
It looks like you haven't seeded the random number generator? <? srand ((double) microtime() * 1000000); $number1 = rand(111, 999); $number2 = rand(1111, 9999); $number3 = rand(11111, 99999); ?> This Should(tm) (in an off-the-cuff kinda way) work. Jason
Look in the manual for mt_rand(). It is better than rand(). I think this question was asked just a couple days ago on this list... Greetings, Jason - the other JM
Thanks Jason, It was the seed problem. I was using rand(0,9) and then count. I will have a look at mt_rand() later today when I have time. Thanks Gary

« previous php.general (#27849) next »