#6066 [Opn->Dup]: shuffle() implementation fails

From: Date: Tue, 01 Oct 2002 20:36:30 +0000
Subject: #6066 [Opn->Dup]: shuffle() implementation fails
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-21147@lists.php.net to get a copy of this message
ID: 6066 Updated by: hholzgra@php.net Reported By: mbravo@acm.org -Status: Open +Status: Duplicate Bug Type: Misbehaving function Operating System: FreeBSD 4.1-Release PHP Version: 3.0.16 New Comment: there's a more recent report ob php 4 behaviour Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#21147) next »