Definiton :
The krsort() function sorts an associative array in descending order, according to the key.
The keys are preserved, i.e. the key-to-value mapping will remain unchanged by the sort operation.
Syntax
The basic syntax of the krsort() function is given with:
krsort(array, sort_flags);
The krsort()
function accepts the following parameters.
Parameter | Description |
---|---|
array | Required. Specifies the array to sort. |
sort_flags |
Optional. Specifies how array items should be compared. Possible values are:
|
Example1 : Given below example Sort an associative array in descending order, according to the key.
Output :
Array
(
[c] => house
[b] => designing
[a] => web
)