you're not maintaining an association somehow between the array of filenames and the filesize/filemod strings that's why your output is getting kind of out of whack..
i used your code and made a few slight changes that hopefully will work for you. i'm sure someone could make this a lot more effecient..
<?php
echo "<table border=\"1\">\n";
$fileList = array();
// Directory name specified
$folder = "/web/test";
// Open the directory
$handle = opendir($folder) or die('Unable to open folder '.$folder);
while ($file = readdir ($handle))
{
// Remove the . and .. and folders
if ($file=="." or $file==".." or is_dir("$folder/$file")) continue;
if (is_file("$folder/$file"))
{
$filetmp = $file;
// Setup some common file size measurements.
$kb=1024;
$mb=1048576;
$gb=1073741824;
$size = filesize("$folder/$file");
$link = "<a href=\"$folder/$file\">$file</a>";
// Last modified date
$file_mod = date ("M d Y", filemtime("$folder/$file"));
// Format file size
if ($size >= $gb)
{
$show_filesize = number_format(($size / 1073741824),0) . " GB";
}
elseif ($size >= $mb)
{
$show_filesize = number_format(($size / 1048576),0) . " MB";
}
elseif ($size >= $kb)
{
$show_filesize = number_format(($size / 1024),0) . " KB";
}
elseif ($size >= 0)
{
$show_filesize = $size . " bytes";
}
else
{
$show_filesize = "0 bytes";
}
$fileList[] = "$filetmp,$show_filesize,$file_mod";
}
}
// Close the directory
closedir($handle);
rsort($fileList);
reset($fileList);
for($i=0; $i<sizeof($fileList); $i++)
{
$holder = explode(",",$fileList[$i]);
// Print into table
echo "<tr><td valign=\"middle\" align=\"left\"><font face=\"arial\" size=\"2\"> $holder[0] </font></td>\n";
echo "<td valign=\"middle\" align=\"left\"><font face=\"arial\" size=\"2\"> $holder[1]</font></td>\n";
echo "<td valign=\"middle\" align=\"left\"><font face=\"arial\" size=\"2\"> $holder[2]</font></td></tr>\n";
}
echo "</table>";
clearstatcache();
?>