The PHP array function array_change_key_case ( ) will change the key of an array to either lower case or upper case depending upon the parameter specified.The PHP array function array_change_key_case ( ) accepts two parameter.
- An array
- The CASE
The first parameter we feed this function is the target array. The second parameter allows you to specify either CASE_LOWER or CASE_UPPER. If you do not specify a second parameter this function will default to using CASE_LOWER to change the case of all keys in the array.
SYNTAX:
array_change_key_case(array,case)
EXAMPLE OF PHP array function array_change_key_case ( ) :
<?php $info=array("name"=>"amit","age"=>"22","address"=>"Nepal"); $info = array_change_key_case($myCarInfo, CASE_UPPER); foreach ($info as $key => $value) { echo "$key | $value <br />"; } ?>
Output:
NAME | amit AGE | 22 ADDRESS | Nepal
Similar Example: