Loader

array_change_key_case

Returns an array with all keys from array lowercased or uppercased. Numbered indices are left as is. Test array_change_key_case online.

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

Enter a array in the following way: [key1 => value1, key2 => value2, value3]

PHP Documentation by the PHP Documentation Group


array_change_key_case

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

array_change_key_caseChanges the case of all keys in an array

Description

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

Returns an array with all keys from array lowercased or uppercased. Numbered indices are left as is.

Parameters

array

The array to work on

case

Either CASE_UPPER or CASE_LOWER (default)

Return Values

Returns an array with its keys lower or uppercased, or FALSE if array is not an array.

Errors/Exceptions

Throws E_WARNING if array is not an array.

Examples

Example #1 array_change_key_case() example

<?php
$input_array 
= array("FirSt" => 1"SecOnd" => 4);
print_r(array_change_key_case($input_arrayCASE_UPPER));
?>

The above example will output:

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

Notes

Note:

If an array has indices that will be the same once run through this function (e.g. "keY" and "kEY"), the value that is later in the array will override other indices.


PHP Documentation

Copyright © 1997 - 2016 by the PHP Documentation Group. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution 3.0 License or later. A copy of the Creative Commons Attribution 3.0 license is distributed with this manual. The latest version is presently available at » http://creativecommons.org/licenses/by/3.0/.