php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31058 array_change_key_case recursive option
Submitted: 2004-12-10 21:53 UTC Modified: 2021-02-23 15:32 UTC
Votes:7
Avg. Score:4.1 ± 1.1
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:5 (71.4%)
From: veeeee at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: Arrays related
PHP Version: 5.0.2 OS:
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: veeeee at gmail dot com
New email:
PHP Version: OS:

 

 [2004-12-10 21:53 UTC] veeeee at gmail dot com
Description:
------------
It would be quite handy were there an option (optional 3rd parameter) to array_change_key_case so that it would recurse into multi-dimensional arrays so one would not need to create work arounds such as:

function ack_r($array, $case) 
{
  $array = array_change_key_case($array, $case);
  foreach ($array as $key => $value) {
    if ( is_array($value) ) {
      $array[$key] = ack_r($value, $case);
    }
  }
  return $array;
}





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-24 10:27 UTC] aharvey@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2010-09-24 10:27 UTC] aharvey@php.net
Re-requested in request #52917.
 [2010-09-24 17:52 UTC] luis dot pessoa67 at ibest dot com dot br
another way to do it:

    function ack_r3(&$array, $case=CASE_LOWER, $flag_rec=false) 
    {
      $array = array_change_key_case($array, $case);
      if ( $flag_rec ) {
        foreach ($array as $key => $value) {
            if ( is_array($value) ) {
                ack_r3($array[$key], $case, true);
            }
        }
      }
    }

note that: ack_r3($array, $case, false) <=> array_change_key_case($array, $case)
 [2018-02-11 17:52 UTC] cmb@php.net
-Package: *General Issues +Package: Arrays related
 [2021-02-23 15:32 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-02-23 15:32 UTC] cmb@php.net
I don't see much point in adding this feature to php-src, since it
can trivially be implemeted in userland code, and there doesn't
appear to big downside in doing so.

If anybody still feels strongly about this, please pursue the RFC
process[1].

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC