The function below will return a sorted array of directories & files in the requested directory. No hidden (/^./) files are listed. Copy and paste away.
function dir_list($dir)
{
$dl = array();
if ($hd = opendir($dir))
{
while ($sz = readdir($hd)) { if (preg_match("/^\./",$sz)==0) $dl[] = $sz; }
closedir($hd);
}
asort($dl);
return $dl;
}