Req #31058 [Opn->Wfx]: array_change_key_case recursive option
| From: | cmb@php.net | Date: | Tue, 23 Feb 2021 15:32:06 +0000 |
| Subject: | Req #31058 [Opn->Wfx]: array_change_key_case recursive option | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232359@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=31058&edit=1
ID: 31058
Updated by: cmb@php.net
Reported by: veeeee at gmail dot com
Summary: array_change_key_case recursive option
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Arrays related
PHP Version: 5.0.2
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
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>
Previous Comments:
------------------------------------------------------------------------
[2010-09-24 17:52:44] 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)
------------------------------------------------------------------------
[2010-09-24 10:27:41] aharvey@php.net
Re-requested in request #52917.
------------------------------------------------------------------------
[2004-12-10 21:53:24] 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;
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=31058&edit=1