Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Sort array numerically descending

this question looks like it should have a simple answer but google and the php manual are being no help to me, maybe I just don't understand what they are telling me.

I have an array example:

$outcomes_array = array(1,4,2,3,5);

It will always contain just numbers, how do I go about sorting this array so that it is always in descending order?

so output I want:

$outcomes_array[0] = 5
$outcomes_array[1] = 4
$outcomes_array[2] = 3

and so on...

Thanks :)

like image 782
George Reith Avatar asked May 26 '11 14:05

George Reith


1 Answers

Use rsort().

like image 93
rid Avatar answered Oct 03 '22 17:10

rid