Code below takes a directory and creates an array of folder names appearing under the directory. How can order the folder names inside the array by alpha?
function get_dirs($dir) {
$array = array();
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if($entry!='.' && $entry!='..') {
$entry2 = $dir."/".$entry;
if(is_dir($entry2)) {
$array[] = $entry;
}
}
}
$d->close();
return $array;
}