PHP array_change_key_case() Function
Complete PHP Array Reference Manual
Example
Convert all keys of an array to uppercase:
" 35 " , " Ben " => " 37 " , " Joe " => " 43 " ) ; print_r ( array_change_key_case ( $age , CASE_UPPER ) ) ; ?>Run Example »
Definition and Usage
The array_change_key_case() function converts all keys of an array to uppercase or lowercase.
Syntax
array_change_key_case(
array
,
case
);
| Parameters | Description |
|---|---|
| array | Required. Specifies the array to use. |
| case | Optional. Possible values:
|
Technical Details
| Return Value: | Returns an array with lowercase keys, or an array with uppercase keys, or if array it is not an array, returns FALSE. |
|---|---|
| PHP Version: | 4.2+ |
More examples
Example 1
Convert all keys of an array to lowercase:
"35","Ben"=>"37","Joe"=>"43"); print_r(array_change_key_case($age,CASE_LOWER)); ?>Run Example »
Example 2
If two or more keys are identical after array_change_key_case() runs (such as "b" and "B"), the last element will overwrite the others:
"Cat","B"=>"Dog","c"=>"Horse","b"=>"Bird"); print_r(array_change_key_case($pets,CASE_UPPER)); ?>Run Example »
Complete PHP Array Reference Manual