PHP array_​change_​key_​case Function



array_​change_​key_​case () is an another PHP prebuilt / default array function, This function is basically allows user to do the array keys lower or uppercase. It will rturn null and will Throw E_WARNING if array is not an array.

array_​change_​key_​case () is an another PHP prebuilt / default array function, This function is basically allows user to do the array keys lower or uppercase. It will rturn null and will Throw E_WARNING if array is not an array.

Syntax of array_​change_​key_​case () :

array_change_key_case(array, case)

array (required) : It is the array for which we need to change the case.
case (optional) : this needs to be passed like CASE_UPPER or CASE_LOWER, if not pass any ‘case’ it will return CASE_LOWER.

Example 1 :

<?php
	$salary = array("MonI" =>"10000", "SoNu"=>"15000", "PrAkHar"=>"45000");
	print_r(array_change_key_case($salary,CASE_UPPER));
?>

Output will be :

Array ( [MONI] => 10000 [SONU] => 15000 [PRAKHAR] => 45000 )

Example 2 :

<?php
  
// PHP code to describe array_change_key_case()
function change_case($array_value){
    return(array_change_key_case($array_value, CASE_LOWER));
}
  
$array_change = array("RoHIT" => 45, "RaHuL" => 30, "SaRITA" => 29, "RaKUL" => 55, "KaNAV" => 10);
print_r(change_case($array_change));
?>

Output will be :

Array ( [rohit] => 45 [rahul] => 30 [sarita] => 29 [rakul] => 55 [kanav] => 10 )

In the previous post I described regarding the PHP array_​pop Function

Hope this article helps you in PHP development and understandings of Array. Stay tuned for more PHP Tutorials, Hope you enjoyed reading, if you need the professional PHP, PHP Framework and Magento 2 Development we can help you, just Click on the Link and send me your requirements.