"35", "Ben" => "37", "Joe""> "35", "Ben" => "37", "Joe"" />
Easy Tutorial
❮ Php Ref Filter Func Xml Utf8 Encode ❯

PHP array_change_key_case() Function

Complete PHP Array Reference Manual

Example

Convert all keys of an array to uppercase:

<?php
$age = array("Peter" => "35", "Ben" => "37", "Joe" => "43");
print_r(array_change_key_case($age, CASE_UPPER));
?>

Definition and Usage

The array_change_key_case() function converts all keys in an array to lowercase or uppercase.


Syntax

Parameter Description
array Required. Specifies the array to use.
case Optional. Possible values: CASE_LOWER - Default. Converts array keys to lowercase.<br> CASE_UPPER - Converts array keys to uppercase.

Technical Details

Return Value: Returns an array with lowercase keys or uppercase keys, or FALSE if the input is not an array.
PHP Version: 4.2+
--- ---

More Examples

Example 1

Convert all keys of an array to lowercase:

Example 2

After running array_change_key_case(), if there are two or more identical keys (e.g., "b" and "B"), the last element will overwrite the others:


❮ Php Ref Filter Func Xml Utf8 Encode ❯