$dir = $_SERVER['DOCUMENT_ROOT'].'/tree/';
function scandir_detail($path)
{
$files=array();
if(is_dir($path))
{
$temp=scandir($path);
foreach($temp as $file)
{
if($file != '.' && $file != '..')
{
if (is_dir($path.$file)) {
$files[$file]=scandir_detail($path.$file."/");
}else
{
$files[]=$file;
}
}
}
}
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(scandir_detail($dir));