#6066 [Dup->Bgs]: shuffle() implementation fails
| From: | sniper@php.net | Date: | Tue, 01 Oct 2002 21:22:06 +0000 |
| Subject: | #6066 [Dup->Bgs]: shuffle() implementation fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-21167@lists.php.net to get a copy of this message | ||
ID: 6066
Updated by: sniper@php.net
Reported By: mbravo@acm.org
-Status: Duplicate
+Status: Bogus
Bug Type: Misbehaving function
Operating System: FreeBSD 4.1-Release
PHP Version: 3.0.16
New Comment:
and it's better to add comments to that one than have this open..
Previous Comments:
------------------------------------------------------------------------
[2002-10-01 15:36:30] hholzgra@php.net
there's a more recent report ob php 4 behaviour
------------------------------------------------------------------------
[2000-08-10 05:45:44] waldschrott@php.net
There´s no information in the docs which logic shuffle() uses, should
be added....
------------------------------------------------------------------------
[2000-08-10 05:35:18] mbravo@acm.org
Detailed description -
an array of 8 elements, being shuffled repeatedly, with
srand((double)microtime()*100000) being called each time, produces very
unrandom results, namely, only 3 elements of 8 ever land in the first
row (tested for 3x24hours).
Testing platform was an installation of Tobias Ratschiller phpAds (I
will be submitting a patch to it which gets rid of shuffle() RSN)
While the same application (phpAds) using the same shuffle() method
worked ok on Linux (2.2.x), I naively believe that actual
implementation of shuffle() might be somehow improved, inctead of
relying on system's random generator being nicely symmetrical (if I
understood the implementation correctly). Replacing usage of system
random generator with mt_rand (internally) might also be a good idea.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=6066&edit=1