note 36394 deleted from ref.math by didou

From: Date: Wed, 08 Oct 2003 14:07:37 +0000
Subject: note 36394 deleted from ref.math by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58048@lists.php.net to get a copy of this message
Note Submitter: paul.vaughan@weston.ac.uk ---- The code: for ($j=1; $j<10001; $j++) { print (rand(0, $j)."<br>"); } ...produces the same, IDENTICAL ten thousand random numbers each and every time. (PHP 4.3.3) Putting srand() before the loop stops this happening: srand(); for ($j=1; $j<10001; $j++) { print (rand(0, $j)."<br>"); } Woo-hoo! Lots of random numbers!! I hope this info is useful to someone. It took me a while to source rand() as the cause of the problem. Vaughany.

« previous php.notes (#58048) next »