note 45598 added to function.rand

From: Date: Sun, 12 Sep 2004 13:58:30 +0000
Subject: note 45598 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-76526@lists.php.net to get a copy of this message
>>Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or >>mt_srand() as this is now done automatically.<< Do realize that you don't HAVE to call srand, but if you don't you get the same results every time... Took me quite a while to get to that conclusion, since I couldn't figure it out: foreach($Unit AS $index => $value) { srand() ; $rand_pos_x = rand(0, $EVAC['x_max']) ; $rand_pos_y = rand(0, $EVAC['y_max']) ; } works, but: foreach($Unit AS $index => $value) { $rand_pos_x = rand(0, $EVAC['x_max']) ; $rand_pos_y = rand(0, $EVAC['y_max']) ; } doesnt even though they say it should. I'm using Windows XP Pro (Windows NT EVOLUTION 5.1 build 2600), PHP Version 4.3.3, CGI/FastCGI. ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45598 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45598&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45598&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76526) next »