← All built-ins / ksort()
ksort()
ksort(array &$a): bool
Parameters
| Name | Type | Description |
|---|---|---|
| $a | array | map to sort by key (by reference) |
Return value
true; sorted ascending by key, key/value association kept.
Example
$m = ["b" => 2, "a" => 1];
ksort($m);
echo implode(",", array_keys($m));a,b