Page 1 of 1

reverse the order of an array's elements

Posted: Sun Nov 16, 2008 2:16 pm
by FlashPack
lets say that we have the following array :

Code: Select all

$array=array('1','2','3','4','5');
and we want to reverse the order of the elements to be like this :

Code: Select all

$array=array('5','4','3','2','1');
is there a direct function to do that ?

Re: reverse the order of an array's elements

Posted: Sun Nov 16, 2008 2:28 pm
by Syntac

Re: reverse the order of an array's elements

Posted: Sun Nov 16, 2008 3:29 pm
by FlashPack
rsort() reverse the order alphabetically :!:
but array_reverse() did the job :D

thank you so much