|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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;
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
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)