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
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:
MUST BE VALID
Solve the problem:
40 - 18 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC