PHP - ksort
Trieda
Metóda - ksort
(PHP 4, PHP 5, PHP 7)
Sorts an array by keys.
Procedurálne
- function ksort (array &$array, int $sort_flags = SORT_REGULAR) : bool
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| &$array | array | The input array. | |
| $sort_flags | int | SORT_REGULAR | The optional parameter. We can use the following flags:
|
Mávratovej hodnoty
Vracia: bool
TRUE or FALSE depending on whether sorting was successful or not.
Príklady
<?php
$array = ['b' => 3, 'c' => 1, 'a' => 2];
ksort($array);
print_r($array);
