note 50650 deleted from function.array-change-key-case by didou
| From: | didou@php.net | Date: | Sat, 27 Jan 2007 00:11:27 +0000 |
| Subject: | note 50650 deleted from function.array-change-key-case by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122252@lists.php.net to get a copy of this message | ||
Note Submitter: benles at bldigital dot com
----
In case you want to find the original case of a key:
$arr = Array( "a"=>1, "B"=>2);
function array_get_key_case($arr, $k)
{
$s = strtolower($k);
foreach (array_keys($arr) as $key) if (strtolower($key) == $s) return $key;
return $k;
}
// Should print aBC
echo array_get_key_case($arr, "A");
echo array_get_key_case($arr, "B");
echo array_get_key_case($arr, "C");