I'm using the following PHP code to list all files and folders under the current directory:
<?php
$dirname = ".";
$dir = opendir($dirname);
?>
<?php
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != "..") and ($file != "index.php"))
{
echo("<a href='$file'>$file</a> <br />");
}
}
?>
The problem is list is not ordered alphabetically (perhaps it's sorted by creation date? I'm not sure). How can I make sure it's sorted alphabetically?