PHP array_change_key_case () function

PHP array_change_key_case() function  is used  to change keys contained in array from one case to another i.e from Lowercase  to uppercase or from Uppercase to lowercase.

Below examples shows how to change keys to uppercase


<?php
$marks=array("Eric"=>"60","Ben"=>"60","John"=>"43");
print_r(array_change_key_case($marks,CASE_UPPER));
?>

PHP array_change_key_case function

Syntax

array_change_key_case(arrayname,casetype);

Parameters:

Array-The function requireds array defined and assinged variables.

Case-there are only two possible values i.e CASE_LOWER-its always the default value of keys.changes keys to lowercase from uppercase

CASE_UPPER-changes the keys to uppercase from lowercase.

Below examples changes keys from uppercase to lowercase

<?php
$marks=array("Eric"=>"60","Ben"=>"60","John"=>"43");
print_r(array_change_key_case($marks,CASE_LOWER));
?>

If there are two keys that will be equal after running array_change_key_case() function, eg (d and D),the array will override the other.

<?php
$animals=array("a"=>"Cow","B"=>"Goat","c"=>"Horse","b"=>"Bird");
print_r(array_change_key_case($animals,CASE_UPPER));
?>

See Complete  Array Functions :PHP Array Functions

About the Author: Eric K

My name is Eric.Am a software developer with skills in Php,Mysql, Java , Android,Node.js Above all, I have certification in Cisco Networking Associate (CCNA) and holds degree in Information Technology. Hire me: Email : kawi3462@gmail.com