PHP rsort() Function
Complete PHP Array Reference Manual
Example
Sort the elements of the $cars array in descending alphabetical order:
Run Example »
Definition and Usage
The rsort() function sorts a numeric array in descending order.
**Tip:** Please use sort() function sorts a numeric array in ascending order.
Syntax
rsort(
array,sortingtype
);
| Parameters | Description |
|---|---|
| array | Required. Specifies the array to sort. |
| sortingtype | Optional. Specifies how to arrange the elements/items of the array. Possible values:
|
Technical Details
| Return Value: | Returns TRUE on success, FALSE on failure. |
|---|---|
| PHP Version: | 4+ |
More examples
Example 1
Sort the elements of the $numbers array in descending numeric order:
Run Example »
Example 2
Treat each item as a number and sort the elements of the $cars array in descending order:
Run Example »
Complete PHP Array Reference Manual