note 36394 added to ref.math

From: Date: Wed, 08 Oct 2003 13:42:10 +0000
Subject: note 36394 added to ref.math
Groups: php.notes 
Request: Send a blank email to php-notes+get-58046@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/ref.math.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36394 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36394&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36394&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58046) next »