Bug #6066: shuffle() implementation fails

From: Date: Thu, 10 Aug 2000 09:35:18 +0000
Subject: Bug #6066: shuffle() implementation fails
Groups: php.dev 
Request: Send a blank email to php-dev+get-28321@lists.php.net to get a copy of this message
From: mbravo@acm.org Operating system: FreeBSD 4.1-Release PHP version: 3.0.16 PHP Bug Type: Misbehaving function Bug description: shuffle() implementation fails 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.

« previous php.dev (#28321) next »