A question about reverse sorting
Posted: Wed Apr 04, 2007 9:53 am
I have a php page which looks in a documents folder and pulls all the names and hyperlinks them. The names of the douments start with a date (for example, "01_09_07 Document 1" and "03_06_07 Document 2")
Currently, there is no real sort. The file system automatically sorts them lower numbers to higher.
My clients wants them sorted in descending order so that the most recent documents appear before the older documents.
I am sure it's easy to do; alas, I am a noob.
Here is my code:
Is there something easy to change or add?
Dumb it down for me due to my afor-mentioned noob-ness.
Please and thank you.
Currently, there is no real sort. The file system automatically sorts them lower numbers to higher.
My clients wants them sorted in descending order so that the most recent documents appear before the older documents.
I am sure it's easy to do; alas, I am a noob.
Here is my code:
Code: Select all
<?php
$dir = "../esmpd_minutes";
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<li class='.listitem'><a href=\"" . $dir . "/" . $file . "\">" . $file . "</a></li><br />\n";
}
}
closedir($handle);
}
?>Dumb it down for me due to my afor-mentioned noob-ness.
Please and thank you.