|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25247 Shuffle() method doesn't work properly
Submitted: 2003-08-26 05:44 UTC Modified: 2003-09-02 18:15 UTC
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jeroen at kesh dot nl Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 4.3.3 OS: Windows 2000 Server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jeroen at kesh dot nl
New email:
PHP Version: OS:


 [2003-08-26 05:44 UTC] jeroen at kesh dot nl
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; 

$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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-26 07:17 UTC]
Try calling srand(time()); before the shuffle.
 [2003-09-02 18:15 UTC]
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.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 20:01:30 2024 UTC