|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
49 - 44 = ?
Subscribe to this entry?

 [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-2023 The PHP Group
All rights reserved.
Last updated: Mon Jun 05 00:03:38 2023 UTC