I have a script to read the files from a directory into an array and list them, sorted by upload date. The list works just fine and the dates are right, but it is not sorted. I don’t get any error messages and I can see anything wrong.
Here’s the script.
[code=php]
if ($open = @opendir(‘.’))
{while (($read = readdir($open)) !== false)
{if (($read != ‘.’) && ($read != ‘..’) && ($read != basename($_SERVER[‘PHP_SELF’])) && ($read != “.htaccess”))
{$files = array($read => filectime($read));
arsort($files, SORT_NUMERIC);
foreach($files as $key => $value)
{echo ‘<li><a href=”‘.$key.'”>’.$key.'</a> (Uploaded: ‘.gmdate(“j M y”, $value).’)</li>’;}
}
}
closedir($open);
}
else {echo ‘Could not open directory’;}
From this I get this list (the files are just random ones while I get it working):
december.html (Uploaded: 4 Sep 08)
june.html (Uploaded: 4 Sep 08)
september.html (Uploaded: 4 Sep 08)
ImprovingRelations3.doc (Uploaded: 13 Sep 08)
%fog.doc (Uploaded: 4 Sep 08)
fo%g.doc (Uploaded: 4 Sep 08)
Anyone have any ideas why the sort isn’t working?
Thanks
MGC