I have written a script that generates a new file for each month. The user has a link to the current months file.
I would like to present an archive list displaying all of the files (apart from the current month) in one list sorted with the newest one at the top.
I use the following code to get the files (all filenames are in the form WLmonthyear.TXT.
$handle=opendir('.');
while ($file = readdir($handle)) {
if ((substr($file,0,2) == "wl") && $file != $filename) {
$chopstring = substr($file, 2 , strlen($file) - 6);
$chopyear = substr($chopstring, -4);
$chopmonth = ucwords(substr($chopstring,0,strlen($chopstring) - 4));
echo "<font face=\"Courier New, Courier, mono\">  ";
echo "<a href=\"weblog.php3?log=$file\">$chopmonth $chopyear</a></font><br>";
}
}
closedir($handle);
What is the best way to sort with the newest file first ?
TIA,
Andrew