Arrays : Changing cases
November 6th, 2009 | by Drew |This form of array declaration allows one to change the case from uppercase to lowercase and vice versa. The syntax goes as follows:
array_change_key_case(array,case)
The array part, specifies which table or array to use and is a required field which is not the case with the key which is automatically assigned a value. An example of it’s use can be seen below:
$a=array('a'=>“Mouse”,’b'=>”Rat”,’c'=>”Rodent”,’d'=>”Cat”);
print_r(array_change_key_case($a,CASE_UPPER));
?>
The output of the said commands will be:
Array ( [A] => Mouse [B] => Rat [C] => Rodent [D] => Cat)
Another example of it’s use would be:
$a=array('a'=>“Mouse”,’B'=>”Rat”,’c'=>”Rodent”,’b'=>”Cat”);
print_r(array_change_key_case($a,CASE_UPPER));
?>
That returns the following values respectively:
Array ( [A] => Mouse [B] => Rat [C] => Rodent [D] => Cat)
In the next post, we would discuss an array function that divides a large array into several chunks of separate arrays.

Sorry, comments for this entry are closed at this time.