php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48110 Add Freeze Array for shuffle
Submitted: 2009-04-29 16:14 UTC Modified: 2014-12-30 10:41 UTC
From: bholbrook at servillian dot com Assigned:
Status: No Feedback Package: Arrays related
PHP Version: Any OS: Irrelevant
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: bholbrook at servillian dot com
New email:
PHP Version: OS:

 

 [2009-04-29 16:14 UTC] bholbrook at servillian dot com
Description:
------------
Add an optional parameter to the shuffle to freeze certain elements in place.

Reproduce code:
---------------
//CURRENTLY
$arrShuffleMe = array(1,2,3,4,5);
shuffle($arrShuffleMe); // produces array(2,4,1,5,3);

//PROPOSED
$arrShuffleMe = array(1,2,3,4,5);
$arrFreezeKeys = array(0,4);
shuffle($arrShuffleMe, $arrFreezeKeys); // produces array(1,3,4,2,5);

$arrShuffleMe = array(1,2,3,4,5);
$arrFreezeKeys = array(0,1);
shuffle($arrShuffleMe, $arrFreezeKeys); // produces array(1,2,4,5,3);

Expected result:
----------------
The shuffle function only shuffles array values whose keys do not match the keys passed in (by array) in the second parameter.

Actual result:
--------------
Feature request. Currently no actual result.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-30 22:59 UTC] levim@php.net
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: Arrays related -Operating System: Any +Operating System: Irrelevant -PHP Version: 5.3.0RC1 +PHP Version: Any
 [2014-04-30 22:59 UTC] levim@php.net
Is this something you are still interested in seeing?
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
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 "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Oct 24 04:03:35 2021 UTC