PHP Reverse Sort Array: rsort() Guide

To reverse sort a PHP array, you can use the built-in function rsort(). An example is shown below.

$numbers = array(5, 2, 8, 1, 9);

rsort($numbers);

print_r($numbers);

The code above will output:

Array
(
    [0] => 9
    [1] => 8
    [2] => 5
    [3] => 2
    [4] => 1
)

This achieves reverse sorting of the array.

bannerAds