note 45598 deleted from function.rand by danbrown
| From: | danbrown@php.net | Date: | Wed, 05 Nov 2008 15:38:29 +0000 |
| Subject: | note 45598 deleted from function.rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146173@lists.php.net to get a copy of this message | ||
Note Submitter: onno at onnovanbraam dot com
----
>>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.