Sort By File Date & Time
We've worked on a directory listing that showed all the files in the directory. I need to now have the same page but sorted by date.
We've worked on a directory listing that showed all the files in the directory. I need to now have the same page but sorted by date.
I've updated that page for you so that it shows the files sorted by date.
How do I reverse the order so that it is in reverse chronological order?
On line 256 I have a function:
// Comparison function
function cmp($filea, $fileb) {
global $dir;
$a = filemtime($dir.$filea);
$b = filemtime($dir.$fileb);
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
You can just change the last line to:
return ($a < $b) ? 1 : -1;
That will reverse the order.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.