#25247 [Fbk->NoF]: Shuffle() method doesn't work properly

From: Date: Tue, 02 Sep 2003 23:15:54 +0000
Subject: #25247 [Fbk->NoF]: Shuffle() method doesn't work properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-47099@lists.php.net to get a copy of this message
ID: 25247 Updated by: sniper@php.net Reported By: jeroen at kesh dot nl -Status: Feedback +Status: No Feedback Bug Type: Arrays related Operating System: Windows 2000 Server PHP Version: 4.3.3 New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2003-08-26 07:17:09] iliaa@php.net Try calling srand(time()); before the shuffle. ------------------------------------------------------------------------ [2003-08-26 05:44:58] jeroen at kesh dot nl Description: ------------ I pick the first two products out of the shuffled array for random productviews on a page. I use 3 or more products. With PHP 4.3.2 it works nice (every refresh another two products). With PHP 4.3.3 it doesn't seem to work. Every time the same products. Same PHP.INI file as 4.3.2 (which worked fine). Reproduce code: --------------- $ads = array(); while($product = mysql_fetch_array($arts)) { $ads[] = $product; } shuffle($ads); $prod = $ads[0]; echo ($prod[name]); $prod = $ads[1]; echo ($prod[name]); Expected result: ---------------- The first two array-records are other products every time at refresh. Actual result: -------------- The first two array-records are the same products each refresh. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25247&edit=1

« previous php.bugs (#47099) next »