php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16926 Shuffle doesn't work
Submitted: 2002-04-30 08:14 UTC Modified: 2002-06-18 19:55 UTC
From: joseppo at hotmail dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.2.0 OS: WinXP
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joseppo at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-04-30 08:14 UTC] joseppo at hotmail dot com
As of PHP 4.2.0, shuffle() doesn't seem to work for me.
The following code always produce the same output:
function make_seed() { // Taken directly from the manual
    list($usec, $sec) = explode(' ', microtime());
    return (float) $sec + ((float) $usec * 100000);
}

srand(make_seed());
$arr = range(1, 10);
shuffle($arr);
print_r($arr);


Further testing shows that I get the same output if I uncomment the srand(), if that's any help.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-01 03:08 UTC] derick@php.net
I could not reproduce this, are you sure the browser is not caching your page?

Derick
 [2002-05-01 05:06 UTC] joseppo at hotmail dot com
Yes, I'm sure. I've tried running it from the command line with the same result.
I've done a little more testing, and it seems that rand() seems to work just fine, so that should more or less exclude the possibility of a bug in srand().

I've also done a full reinstall (just to make sure) without any luck.
 [2002-05-01 12:39 UTC] rodif_bl@php.net
I made patch for this awhile ago. It never was commited.

http://bugs.php.net/bug.php?id=7045
 [2002-06-18 19:55 UTC] sniper@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 23:01:30 2024 UTC