reverse the order of an array's elements

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FlashPack
Forum Newbie
Posts: 5
Joined: Mon Nov 10, 2008 5:37 pm
Location: Egypt

reverse the order of an array's elements

Post 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 ?
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: reverse the order of an array's elements

Post by Syntac »

FlashPack
Forum Newbie
Posts: 5
Joined: Mon Nov 10, 2008 5:37 pm
Location: Egypt

Re: reverse the order of an array's elements

Post by FlashPack »

rsort() reverse the order alphabetically :!:
but array_reverse() did the job :D

thank you so much
Post Reply