Skip to main content
GameDev.net gamedev.net
🔒 Locked

PHP file sorting

Started by Nervo Sep 6, 2003 at 2:07 PM 0 replies 200+ views
Original Post
Nervo
Nervo
I wanted to sort uploaded images on my site so on the index page only the newest ones appear first. I found the function filemtime that gets the last time the file was modified and I know I''ll need an array to go further. I know I can sort them but since its PHP there might be some high level functions that does this but I can''t seem to find any. The way the script works now is simply looping through the specified directory with readdir() and building an array out of it and then later on looping through sequentially and outputting the image. So what I need to do is rebuild the array in order of newest to oldest. I''ll keep digging but if anyone has any good info or resources in the meantime please feel free to share.
|PicRepository|FTP Svc| quote:
I see drunken bimbos who are allowing themselves to be taken advantage of. How can that possibly be arousing? --Mithrandir
Well, R2D22U2..
Nervo
Nervo
nevermind. The php book I have fell short of one crucial piece of information when it came to sorting. It described sort() asort ksort() etc.. but what it failed to describe was that sort() takes an optional flag to sort the index based upon a numerical value instead of just alphabetical which is the default behavior. Thank goodness for online resources! I didn''t want to bloat the code with my homemade functions.
Well, R2D22U2..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.