PHP array_change_key_case() Function

It is an inbuilt function of PHP. The array_change_key_case() function returns an array with all arrays keys in lower case or upper case.


array_change_key_case(array,case);          
 

Parameters

Parameter Description Is compulsory
array Specifies the name of the array to sort. Compulsory
Sort_flags Specifies how to compare the array elements. Optional

Return

PHP Example


<?php  
$vow=array("a"=>"a", "e"=>"e", "i"=>"i", "o"=>"o", "u"=>"u");  
print_r(array_change_key_case($vow,CASE_UPPER));  
?> 
                

Output

Array( [A]=>a [E]=>e [I]=>i [O]=>o [U]=>u )

PHP Example


<?php  
$sal=array("Rahul"=> "10000" , "Ajay"=> "15000" , "Sid"=> "20000" );  
print_r(array_change_key_case( $sal, CASE_LOWER ) );  
?>
                    

Output

Array ( [rahul]=> 10000 [ajay]=> 15000 [sid]=> 20000 )

PHP Example


<?php  
$age=array("RAHUL"=> "10" , "VIKAS"=> "20" , "SID"=> "25"  );  
print_r(array_change_key_case( $age) );  
?> 
                            
                    

Output

Array ([rahul]=> 10 [vikas]=> 20 [sid]=> 25 )