PHP Programing language

adplus-dvertising
array_change_key_case() Function in PHP
Previous Home Next
adplus-dvertising

array_change_key_case()

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

Syntax:
array_change_key_case(array,case);

In above Syntax,"array" specifies the array to use, "case" case values are as follows:

  • CASE_LOWER: Default value and changes the keys to lowercase
  • CASE_UPPER: changes the keys to uppercase

Example:

<?php
$fruit_weight=array("Apple"=>"5kg","Banana"=>"7kg","Mango"=>"10kg");
print_r(array_change_key_case($fruit_weight,CASE_LOWER));
echo "<br/>";
print_r(array_change_key_case($fruit_weight,CASE_UPPER));
?>

Output:

Array ( [apple] => 5kg [banana] => 7kg [mango] => 10kg ) 
Array ( [APPLE] => 5kg [BANANA] => 7kg [MANGO] => 10kg )

Previous Home Next