PHP Array rsort() Function
Last Updated : 17 Mar 2025
The PHP rsort( ) function is used to sort an array in reverse order. This function introduced in PHP 4.0.
Syntax
Parameter
| Parameter | Description | Is compulsory |
|---|---|---|
| array | Specifies the array to use. | compulsory |
| Sort flags | It specifies how to sort the array values. Possible values - SORT_REGULAR - Default. Treat values as they are (don't change types) SORT_NUMERIC - Treat values numerically SORT_STRING - Treat values as strings SORT_LOCALE_STRING - Treat values as strings, based on local settings | Optional |
Returns
The PHP rsort( ) function returns true on success or false on failure.
Example 1
Output:
Array
(
[0] => orange
[1] => mango
[2] => banana
)
Example 2
Output:
Array
(
[0] => 600
[1] => 400
[2] => 220
[3] => 110
[4] => 100
)
Example 3
Output:
Array
(
[0] =>os
[1] => java
[2] =>dbms
[3] => compiler
)
Example 4
Output:
Array
(
[0] =>nexon
[1] =>hexa
[2] =>audi
)
Next TopicPhp-array-search-function