The rsort () function sorts array elements in reverse order by key value. Similar to arsort.
Note: This function assigns a new key name to the cell in array. This will delete the original key name, not just the reorder.
If the call succeeds, TRUE is returned. Otherwise, FALSE is returned.
The second optional parameter contains another sorting flag.
Rsort (array, sorttype) parameter description
Array is required. Input array.
Sorttype is optional. Specifies how to arrange the values of an array. Possible values:
SORT_REGULAR-default. Process with their original type (without changing the type ).
SORT_NUMERIC-process the value as a number
SORT_STRING-process the value as a string
SORT_LOCALE_STRING-process the value as a string based on local settings *.
*: This value is newly added to PHP 4.4.0 and 5.0.2. Before PHP 6, you can use setlocale () to change the region settings of the system. From PHP 6, you must use the i18n_loc_set_default () function.
|The code is as follows:||Copy code|
$ Animals = array ("dog" => "large", "cat" => "medium", "mouse" => "small ");
Rsort ($ animals );
Use KSORT () or KRSORT () to preserve associative keys.