PHP's sort()

software development

#1

I have a script that’s working nicely, to make a gallery out of all images in a directory. However, it’s sorting the files alphabetically. How could I make sort($folder); sort by file modification date, with the most recently modified coming first?


#2

I’m not a PHP expert, but it sounds to me like you need to loop through each file and use stat (http://www.php.net/manual/en/function.stat.php) to get the modification date. You’ll then need to push your results into an array of some sort and then sort your array.

Hope this helps.

  • wil