Array Change Key Case Function in PHP
In this article I explain the PHP array_change_key_case function.
PHP array_change_key_case Function
The array_change_key_case() function returns an array with all keys from input lowercased or uppercased.
Syntax
Parameter in array_change_key_case function
It takes two parameters; they are:
Parameter |
Description |
input |
It specifies an array to work on. |
case |
It is optional parameter and it's possible values are:
- CASE_LOWER - Returns the array key value in lower case.
- CASE_UPPER - Returns the array key value in upper case.
|
Example of array_change_key_case function
<?php
echo "<h1>Upper Case</h1>";
$input_array = array("First" => "Cat", "Second" => "Rat");
echo "<pre>";
print_r(array_change_key_case($input_array, CASE_UPPER));
echo "<h1>Lower Case</h1>";
$input_array = array("First" => "Cat", "Second" => "Rat");
echo "<pre>";
print_r(array_change_key_case($input_array, CASE_LOWER));
?>
Output
