php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34229 shuffle clobbers keys, this is not documented
Submitted: 2005-08-24 08:03 UTC Modified: 2005-08-24 16:16 UTC
From: david dot tulloh at anu dot edu dot au Assigned: dbs (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2005-08-24 08:03 UTC] david dot tulloh at anu dot edu dot au
Description:
------------
shuffle clobbers the keys in the array, this should probably be documented, currently it is not mentioned.

Reproduce code:
---------------
$a = array('hi'=>'a', 'fred'=>'b', 'how'=>'c', 'is'=>'d', 'wilma'=>'e');
shuffle($a);
Array
(
    [0] => b
    [1] => c
    [2] => a
    [3] => e
    [4] => d
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-24 16:11 UTC] dbs@php.net
This affects multiple sorting functions. I'll define a new entity and try to update the affected functions accordingly.
 [2005-08-24 16:16 UTC] dbs@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Now we should be able to delete a bunch of user notes on the subject...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 21:01:33 2025 UTC