Ooops...I didn't read all the way into the first post. You want dir's on top of the list of files. Try this:
<?php
$folder = "."; // Enter the folder name (use . for the current folder)
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_dir($file)) {
echo "$file<br>\n";
}
}
closedir($handle);
}
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
if (!is_dir($file)) {
echo "$file<br>\n";
}
}
closedir($handle);
}
?>
Let me know how it works out.