note 96769 deleted from function.array-change-key-case by danbrown
| From: | danbrown@php.net | Date: | Mon, 15 Mar 2010 16:47:10 +0000 |
| Subject: | note 96769 deleted from function.array-change-key-case by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167064@lists.php.net to get a copy of this message | ||
Note Submitter: mail at vojtechvondra dot cz
----
A simpler version of the recursive version lower on the page:
<?php
/**
* A recursive array_change_key_case function.
* @param array $input
* @param int $case
*/
function array_change_key_case_recursive(array $input, $case = CASE_LOWER)
{
if (!in_array($case, array(CASE_UPPER, CASE_LOWER)))
{
trigger_error("Case parameter '{$case}' is invalid.", E_USER_NOTICE);
}
$input = array_change_key_case($input, $case);
foreach ($input as $key => $array)
{
if (is_array($array))
{
$input[$key] = array_change_key_case_recursive($array, $case);
}
}
return $input;
}
?>