I have a website that contains a manual with many office precedents. When a user uses the HTML upload script it uploads the precedent to a folder on the server. I use the following script to list out all the files in that specific folder.
<?php //define the path as relative
$dir = "./OFFICE PRECEDENTS/Business & Corporate Law";
$webpath =""; //using the opendir function
echo "<ol>";
// Open a known directory, and proceed to read its contents
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (is_dir($dir.'/'.$file)){}
else if ($file == '.'){}
else if ($file == '..'){}
else if ($file == 'index.php'){}
else {
echo "<li><a href='https://manual.malicki-law.ca/$dir/$file'>$file</a></li>
";
}
}
closedir($dh);
}
echo "</ol>";
?>
How can I implement a system to alphabetically sort the list?