Read an array in reverse

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
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Read an array in reverse

Post by Luke »

What is the best way to read an array in reverse (as apposed to just foreach(This as that) {bla})

I need to do a news post administration thinger and the news needs to come up in the reverse order it went in... I will pull it out of a database in an array, but I want to read that array from the end instead of the beginning.

NEVERMIND... I found it

I'm an idiot... array_reverse() :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Why not just pull it out of the database in reverse?

Code: Select all

order by date_field desc
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Yeah, that would work better.
Post Reply