note 86412 added to function.array-rand

From: Date: Fri, 17 Oct 2008 07:35:26 +0000
Subject: note 86412 added to function.array-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-145446@lists.php.net to get a copy of this message
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(). ---- Server IP: 80.64.47.13 Probable Submitter: 80.37.14.51 ---- Manual Page -- http://www.php.net/manual/en/function.array-rand.php Edit -- https://master.php.net/note/edit/86412 Del: integrated -- https://master.php.net/note/delete/86412/integrated Del: useless -- https://master.php.net/note/delete/86412/useless Del: bad code -- https://master.php.net/note/delete/86412/bad+code Del: spam -- https://master.php.net/note/delete/86412/spam Del: non-english -- https://master.php.net/note/delete/86412/non-english Del: in docs -- https://master.php.net/note/delete/86412/in+docs Del: other reasons-- https://master.php.net/note/delete/86412 Reject -- https://master.php.net/note/reject/86412 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145446) next »