array_change_key_case
PHP Manual
PHP Manual»Функції для роботи з масивами»array_change_key_case

array_change_key_case

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

array_change_key_caseChanges the case of all keys in an array

Опис

function array_change_key_case(array $array, int $case = CASE_LOWER): array

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

Параметри

array

The array to work on

case

Either CASE_UPPER or CASE_LOWER (default)

Значення, що повертаються

Returns an array with its keys lower or uppercased.

Приклади

Приклад #1 array_change_key_case() example

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

Поданий вище приклад виведе:

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

Примітки

Зауваження:

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.

To Top