Prova questo codice e vedi che succede ....
Ovviamente provalo in locale.
Codice PHP:
<?php
echo "<pre>" ;
$asd = "" ;
dirExplorer( "./" , 0 , 20 ) ;
echo $asd;
echo "</pre>" ;
function dirExplorer( $path , $step , $stepLimit )
{
$path = trim($path);
// Whitespaces
$ws = "";
for( $i=0 ; $i < $step ; $i++ )
$ws .= "-" ;
$ws .= "|" ;
// CASI BASE
if( !file_exists($path) )
{ echo "" ; return ; }
if ( !is_dir( $path ) )
{ echo $ws."[f]".$path."\n" ; return; }
if( $step>$stepLimit )
{ echo $ws."[X]".$path."\n" ; return ; }
// Stampa valore attuale
echo $ws."[D]".$path."\n";
// RICORSIONE
$datas = scandir($path) ;
// NewPath
$npath = $path ;
if( $npath[ strlen($npath)-1 ]=="/" )
$npath = substr( $npath , 0 , strlen($npath)-1 ) ;
foreach( $datas as $r )
{
if( $r!="." && $r!=".." )
dirExplorer( $npath."/".$r , ++$step , $stepLimit )."\n" ;
}
}
?>

Rispondi quotando