Location: PHPKode > scripts > dirLook > dirlook/dirLook.php
<?php
/*---------------------------------------------------/
V          name: dirLook                             V
V          author: vovikha                           V
V          E-mail: hide@address.com                 V
V          created: 23.05.2008                       V
/----------------------------------------------------*/


// This is a simple class for looking all files in directory and subdirectories 
// You can easy use it as a simple function
// It needs only one  parameter - directory name
class dirLook{
    
    function fPath($dir)
    {
    //arr to collect dir names
    $arrfName = array();
    //default dir path
    $PathDir = $dir."/";
    //
        if ($fd = @opendir($dir)) {
            while (false !== ($fName = readdir($fd))) { 
                if (true == is_dir($PathDir.$fName)&&$fName !== "." && $fName !== ".."){
                    $arrfName = array_merge($arrfName, $this->fPath($PathDir.$fName));
                }
                elseif (false == is_dir($PathDir.$fName)){
                    $arrfName[] = $PathDir.$fName;   
                }
            }
        }else{
            echo "I can't read directory - ".$dir;
        }
        closedir($fd);  
    return $arrfName;   
    }
    
}
//Example
$obj = new dirLook;

//$obj->dir = "."; for current directory
//$obj->dir = ".."; for perent directory

echo "<pre>";
print_r($obj->fPath("."));
echo "</pre>";

?>
Return current item: dirLook