$dir = $_SERVER['DOCUMENT_ROOT'].'/test';
//var_dump($dir);exit; function my_scandir($dir)
{
$files = array();
if ( $handle = opendir($dir) ) {
while ( ($file = readdir($handle)) !== false ) {
if ( $file != ".." && $file != "." ) {
if ( is_dir($dir . "/" . $file) ) {
$files[$file] = my_scandir($dir . "/" . $file);
}else {
$files[] = $file;
}
}
}
closedir($handle);
return $files;
}
} function showTree($files){
echo "<ul>";
foreach($files as $key=>$file){
if(is_array($file)){
echo "<li>".$key;
showTree($file);
}else{
echo "<li>".$file;
}
}
echo "</ul>";
} showTree(my_scandir($dir));