sorting array issues

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
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

Post by SomeOne »

i have alsow an issue on array sorting...
i have array full of date's like
1.12.2006
3.12.2006
2.12.2007
i use sort($myarray);
and then i get
1.12.2006
2.12.2007
3.12.2006
ok, its is sorted, though not right... i want to be sorted by date...
can anyone tell me how to do this? 8O
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

Post by SomeOne »

i have found "usort" function though dont really understand, how to set it up, to work 4 me
anyone? :roll:
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

convert the dates to a unix timestamp, sort that, convert them back again.

Code: Select all

strtotime(), sort(), date()
Post Reply