Reputation: 85
I have an array like this:
The output is as below:
I want to sort the image output from right to left
Does anyone know the solution?
Thanks
Upvotes: 0
Views: 39
Reputation: 43594
You can use sort
to sort the array in ascending order (0 to 30). To reverse all the elements of the sorted array you can use array_reverse
:
$arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
sort($arr);
$arr = array_reverse($arr);
You can also use rsort
to sort directly in descending order:
$arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
rsort($arr);
Upvotes: 1