Tento trik zobrazuje súbory a adresáre v stromovej štruktúre. Zobrazuje veľkosť súborov, veľkosť adresárov (súčet veľkostí súborov v adresáry a jeho podadresároch), počet súborov a podadresárov v adresáry.

<html>
<head>
<style type=text/css>
<!--
    BODY, TABLE, A, input {font-family:Tahoma; font-size:9; color:#000000 };
-->
</style>
</head>
<?
function tree($path,$defaultRoot,$root,$showFiles){
    if (($root<=$defaultRoot) or ($defaultRoot=="-1")){
        $dir = opendir($path);  
        while ($file=readdir($dir)) {
            if (is_dir("$path/$file")){$dirArray[count($dirArray)]="$file";
            }else{$fileArray[count($fileArray)]="$file";};        
        };
        @sort($dirArray);@sort($fileArray);
        for($i=0;$i<count($fileArray);$i++){$dirArray[]=$fileArray[$i];};
        for($s=0;$s<count($dirArray);$s++){
            $file=$dirArray[$s];
            if ($file=="." and $root==0){
                echo "<a href='tree.php?path=$path/$file&amp;showFiles=$showFiles&amp;defaultRoot=$defaultRoot'><b>$file</b></a><br>\n";
            }else if($file==".." and $root==0){
                echo "<a href='tree.php?path=$path/$file&amp;showFiles=$showFiles&amp;defaultRoot=$defaultRoot'><font size='2'><b>$file</b></font></a> ";
                echo convertSize(dirSize("$path"))." ";
                echo countDir("$path")." ";
                echo countFile("$path")." ";
                echo "<br>\n";
            }
            if (($file != ".") and ($file!= "..")){
                if (is_dir("$path/$file")){
                    for($i=0;$i<$root;$i++){echo "<font family='terminal'>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</font>";}
                    echo "<a href='tree.php?path=$path/$file&amp;showFiles=$showFiles&amp;defaultRoot=$defaultRoot'><font     size='2'><b>$file</b></font></a> ";
                    echo convertSize(dirSize("$path/$file"))." ";
                    echo countDir("$path/$file")." ";
                    echo countFile("$path/$file")." ";
                    echo "<BR>\n";
                    tree("$path/$file",$defaultRoot,$root+1,$showFiles);
                }else{
                    if($showFiles=="true"){
                        for($i=0;$i<$root;$i++){echo "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;";}
                        echo "<font color=#444444><b>$file</b></font> ";
                        echo convertSize(filesize("$path/$file"));
                        echo "<BR>\n";
                    };
                };
            };  
        };
    };
};
function countFile($path){
    $dir = opendir($path);  
    while ($file=readdir($dir)) {  
        if (($file != ".") and ($file!= "..")){  
            if (is_dir("$path/$file")){$i=$i+countFile("$path/$file");
            }else{$i++;};
        };  
    };
    if ($i<1){$echo="";}else if ($i==1){$echo="$i súbor";}else if ($i<5){$echo="$i súbory";}else {$echo="$i súborov";}return($echo);
};
function countDir($path){
    $dir = opendir($path);  
    while ($file=readdir($dir)) {  
        if (($file != ".") and ($file!= "..")){if (is_dir("$path/$file")){$i=$i+countDir("$path/$file");$i++;};};  
    };
    if ($i<1){$echo="";}else if ($i==1){$echo="$i adresár";}else if ($i<5){$echo="$i adresáre";}else {$echo="$i adresárov";}return($echo);
};
function dirSize($path){
    $dir = opendir($path);  
    while ($file=readdir($dir)) {  
        if (($file != ".") and ($file!= "..")){  
            if (is_dir("$path/$file")){$size=$size+dirSize("$path/$file");
            }else{$size=$size+filesize("$path/$file");};
        };  
    };
    return($size);
};
function convertSize($size){
    if ($size>1048576){$echo=round($size/1048576)."Mb";
    }else if ($size>1024){$echo=round($size/1024)."Kb";
    }else{$echo=$size."B";}
    return $echo;
}
if (!$path){$path="..";};
if ($defaultRoot==""){$defaultRoot="-1";};
echo "<form action=tree.php method='post'>";
echo "cesta:<input type=text name=path size=30 value=$path>; ";
echo "podadresárov:<input size=1 type=text name=defaultRoot value=$defaultRoot>('-1'=všetky); ";
echo "zobraz súbory:<INPUT TYPE='checkbox' NAME='showFiles' ";
if($showFiles){echo "checked";$showFiles=true;};
echo ">; <input type='submit' value='browse'>";
echo "</form>";
tree($path,$defaultRoot,0,$showFiles);
?>
</html>