PHP - array_change_key_case
Trieda
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
- function array_change_key_case (array $array, int $case = CASE_LOWER) : array
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $array | array | The input array. | |
| $case | int | CASE_LOWER | Can contain the value of one of the following constants:
|
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));
