PHP array_change_key_case() Function

The array_change_key_case() function changes all keys in an array to lowercase to uppercase and array_change_key_case() function changes all keys in an array to uppercase to lowercas.

CASE_LOWER – Default value. Changes the keys to lowercase

CASE_UPPER – Changes the keys to uppercase

CASE_LOWER

$keyandvalue = array("ALEX"=>"45","PRInce"=>"38","jACK"=>"30");
print_r(array_change_key_case($keyandvalue,CASE_LOWER));

Output

Array ( [alex] => 45 [prince] => 38 [jack] => 30 ) 

CASE_UPPER

$keyandvalue = array("alex"=>"45","PRince"=>"38","jaCk"=>"30");
print_r(array_change_key_case($keyandvalue,CASE_UPPER));

Output

Array ( [ALEX] => 45 [PRINCE] => 38 [JACK] => 30 ) 

Leave a Reply

Your email address will not be published. Required fields are marked *