PHP Funcation: array_change_key_case

array_change_key_case: Returns an array with all keys from array lowercased (default) or uppercased

Syntax

array array_change_key_case ( array $array [, int $case = CASE_LOWER ] ); 

Parameters

  • array: The array to work on
  • case: Either CASE_UPPER or CASE_LOWER (default)

Note:
If an array has two or more indexes that will be the same once go through this function (e.g. “keY” and “kEY”), the value that come later in the array will override other indexes.

Example: array_change_key_case()

<?php

$input_array = array("FirSt" => 1, "SecOnd" => 4);

print_r(array_change_key_case($input_array, CASE_UPPER));

?>

Output of above example

Array
(
    [FIRST] => 1
    [SECOND] => 4
)

Example: array_change_key_case()

<?php

$input_array = array("FirSt" => 1, "SecOnd" => 4);

print_r(array_change_key_case($input_array));

?>

Output of above example

Array
(
    [first] => 1
    [second] => 4
)