ID: 25247
Updated by: [EMAIL PROTECTED]
Reported By: jeroen at kesh dot nl
-Status: Open
+Status: Feedback
Bug Type: Arrays related
Operating System: Windows 2000 Server
PHP Version: 4.3.3
New Comment:
Try calling srand(time()); before the shuffle.
Previous Comments:
------------------------------------------------------------------------
[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