How to sort numeric array in descending order with PHP

1 Answer

0 votes
$numbers = array(4, 9, 0, 12, 10, 7, 2, 1);
 
rsort($numbers);

print_r($numbers);




/*
run:

Array
(
    [0] => 12
    [1] => 10
    [2] => 9
    [3] => 7
    [4] => 4
    [5] => 2
    [6] => 1
    [7] => 0
)

*/

 



answered Jun 21, 2022 by avibootz

Related questions

...