array_change_key_case()
array_change_key_case() — Changes the case of all keys in an array.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Returns an array with all keys from array lowercased or uppercased. Numbered indices are left as is.
Signature
array_change_key_case(array $array, int $case = CASE_LOWER): array
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $array | array | The array to work on |
| $case | int | Either CASE_UPPER or CASE_LOWER (default) |
Return value
Returns an array with its keys lower or uppercased.
Example
A runnable snippet:
$input_array = array("FirSt" => 1, "SecOnd" => 4); print_r(array_change_key_case($input_array, CASE_UPPER));
Output:
Array ( [FIRST] => 1 [SECOND] => 4 )
All PHP 8.5 built-in functions
Reference card built from the PHP manual page array_change_key_case() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.