[ ]; $url, 'children'=>$subdir); } } elseif(is_file($path)) { if(($include && !preg_match($include, $url)) || ($exclude && preg_match($exclude, $url))) continue; $files[] = array('url'=>$url); } } } @closedir($dh); return dirsort($files); } function dirsort($files) { usort($files, 'dircomp'); return $files; } function dircomp($a, $b) { if(isset($a['children']) && !isset($b['children'])) return -1; if(isset($b['children']) && !isset($a['children'])) return 1; return strcmp(strtolower($a['url']), strtolower($b['url'])); } echo xinha_to_js(scan($dir,$url)); ?>