PHP Array changekeycase() Function
PHP array_change_key_case() Function
Last Updated : 17 Mar 2025
It is an inbuilt function of PHP. The array_change_key_case() function returns an array with all arrays keys in lower case or upper case.
Syntax
| Parameter | Description | Is compulsory |
|---|---|---|
| array | Specifies the array to use | compulsory |
| case | Case to use(Upper or Lower) | optional |
Important Note: If the second parameter is avoided then by default the keys of array will get converted to lowercase.
Example 1
Output:
Array( [A]=>a [E]=>e [I]=>i [O]=>o [U]=>u )
Example 2
Output:
Array ( [rahul]=> 10000 [ajay]=> 15000 [sid]=> 20000 )
Example 3
If two or more array keys will be the same after running array_change_key_case( ) function, the latest array will override the other.
Output:
Array ([A]=> Agra [B]=> Bengaluru [C]=> Chennai )
Example 4
If we ignore the second parameter in the function array_change_key_case( ) then the keys will be converted to lowercase.
Output:
Array ([rahul]=> 10 [vikas]=> 20 [sid]=> 25 )
Next TopicPhp-array-chunk-function