0

I have this kind of dynamic array :

Array
(
    [0] => 2011-12
    [1] => 2018-19
    [2] => 2016-17
    [3] => 2010-11
    [4] => 2009-10
    [5] => 2007-08
    [6] => 2012-13
    [7] => 2015-16
    [8] => 2017-18
    [9] => 2008-09
    [10] => 2013-14
    [11] => 2014-15
)

How do I sort it in descending order ?

like I want this type of output :

Array
(
    [0] => 2018-19
    [1] => 2017-18
    [2] => 2016-17
    
)

and so on ....

Parthavi Patel
  • 739
  • 11
  • 28

1 Answers1

1

I guess you are just trying to order them by Descending order. Try: rsort($yourArray); The output will be :

Array
{
[13] => 2018-19
[12] => 2017-18
[11] => 2016-17
...
}

The indexing will be the same because the rsort() function all it does is just sorting your array in reverse mode (which I think that's what you are trying to do).

Leo Ramadani
  • 223
  • 1
  • 11