NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - array_change_key_case

Trieda

Koreň \ Bez triedy

Metóda - array_change_key_case

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

The function is used to change the array key names to uppercase or lowercase. Numeric indexes remain unchanged.

Note: The function works only with the first dimension of the array.

Beware: The function does not support multibyte characters - accent characters stay unchanged!

Procedurálne

Parametre

NázovDátový typPredvolená hodnotaPopis
$arrayarray

The input array.

$caseint CASE_LOWER

Can contain the value of one of the following constants:

  • CASE_LOWER (lowercase)
  • CASE_UPPER (uppercase)

Mávratovej hodnoty

Vracia: array

Returns the resulting array or false if the input is not an array.

Note: Throws E_WARNING if the input is not an array.

Príklady

<?php
$array = [
    'SoMeThInG_MesSy' => 1,
    'neXtKey' => 2,
    'lower_case' => 3,
    'UPPER_CASE' => 4,
    'ABCČĎĚ' => 'multibyte'
];

print_r(array_change_key_case($array, CASE_LOWER));
print_r(array_change_key_case($array, CASE_UPPER));

Súvisiace manuály

        Aktivity