I am working on modifying a simple website. This website has a page that shows a clients files available for download(if applicable). At the moment these files are just in random order with no specific details. I would like to be able to have them in decending order based on time stamp that they were made available. Also including their file size. This is using php to show the files, do I need to have the directory already sorted before displaying them? if so would that be a separate script and when would it be run? Or can I sort them as they are displayed in the follwoing code?
<div id="f2">
<h3>Files Available for Download</h3>
<p>
<?php
// list contents of user directory
if (file_exists($USER_DIRECTORY)) {
if ($handle = opendir($USER_DIRECTORY)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "<a href='download_file.php?filename=".urlencode($entry)."'>".$entry."</a><br/>";
}
}
closedir($handle);
}
}
?>
</p>
</div>
Very new to php, so any help is appreciated.