I have a directory index file to read the contents of a direvtory, and display: An Altered file name, Modified date, and descroption taken from within the file. It builds an HTML table to display the list. My problem is that I can't figure out how to do a descending sort by file name when it displays the list. HELP!!!!!!!!!!!
Code:
<html>
<head>
</head>
<body>
<center>
<?php
echo "<table cellspacing=0 cellpadding=8 width=70%>";
echo "<tr>
<td bgcolor=000099></td>
<td bgcolor=000099><font color=eeeeee size=-1em><b><center>FILE</center></b></font></td>
<td bgcolor=000099><font color=eeeeee size=-1em><b><center>MODIFIED</center></b></font></td>
<td bgcolor=000099><font color=eeeeee size=-1em><b><center>DESCRIPTION</center></b></font></td></tr>";
if ($handle = opendir('.'))
{
$i="1";
while (false !== ($file = readdir($handle)))
{
if (preg_match("/FileA\d+\.php/i",$file))
{
$phpStripped = str_replace(".php", "", $file);
$earSpace = str_replace("FileA", "File #", $phpStripped);
$earSpace = strtoupper($earSpace);
echo "<tr><td>$i</td><td><font size=2em><b><a href=$file>$earSpace</a> </b></font></td>";
$t=date("d.M.Y H:i", filemtime($file));
echo " <td><font size=2em><b>$t</font></b></td>" ;
$fp = fopen($file, "r");
$contents = fread($fp, filesize($file));
$descript1 = explode("\n", $contents);
$descript2 = str_replace("<td>", "", $descript1[28]);
$description = str_replace("</td>", "", $descript2);
echo " <td><font size=2em><b>$description</b></font></td></tr> ";
++$i;
}
}
closedir($handle);
}
echo "</table>";
?>
</center>
</body>
</html>