note 86368 deleted from function.array-rand by danbrown
| From: | danbrown@php.net | Date: | Tue, 27 Jan 2009 02:21:35 +0000 |
| Subject: | note 86368 deleted from function.array-rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149818@lists.php.net to get a copy of this message | ||
Note Submitter: alvaro at demogracia dot com
----
As of PHP/5.2.6, array_rand() is not reliable in Windows (see bug #45301):
<?php
$data = range(1, 20000);
for($i=0; $i<10; $i++){
echo array_rand($data) . "\n";
}
?>
This prints something like:
7735
15498
3590
13677
15498
3590
13677
15498
3590
13677
You only get 4 different values when choosing among 20,000.
I suggest you build your own random picker and base it in mt_rand().