Sorting Direcroty file by filemtime()

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Sorting Direcroty file by filemtime()

Post by kendall »

Hello,

Im trying to list the contents of a directory sorting the file by the time they were uploaded...so i used the modified time to base this.

My theory would be to set and array of the files and set the key to be the filetime() of the file. then do a krsort() to sort by unixt time stamp in descending order...

is this an appropriate step in sorting files by the time they were uploaded?

Any suggestions on another approach?

Kendall
User avatar
mchaggis
Forum Contributor
Posts: 150
Joined: Mon Mar 24, 2003 10:31 am
Location: UK

Post by mchaggis »

No suggestion, but yes i'd use the filemtime(), but depends on what exactly you are doing
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

mMm, your way seems more sensible though. But I rarely have any luck working with files - most of the time. So when uploaded, I'd register the filename into a table in the database then when sorting, I call "ORDER BY id DESC".

Well, it's another approach I guess.

-Nay
Post Reply