PHP array_arsort( ) function
Last Updated : 17 Mar 2025
The array_arsort( ) function is an inbuilt function of PHP. The array_arsort( ) function is used to sort an array in reverse order and the function maintains index association. This function was introduced in 4.0.
Syntax
Parameters
| Parameter | Description | Is compulsory |
|---|---|---|
| array | Specifies the name of the array to sort. | compulsory |
| Sort_flags | Specifies how to compare the array elements. | Optional |
Return Values
The array_arsort( ) function returns true on success and false on failure.
Example 1
Output:
Array
(
[1] =>noida
[2] =>hyderabad
[0] => Bengaluru
)
Example 2
Output:
Array
(
[OS] => 95
[data structure] => 89
[compiler] => 68
)
Example 3
Output:
Array
(
[ganguly] => 46
[sachin] => 45
[virat] => 29
)
Example 4
Output:
Array
(
[c] =>yamuna
[b] =>narmada
[a] => ganga
)
Next TopicPhp-array-asort-function