public static function listDirStructure($dir = '.', $filter = null, $recurse = true, $strip_root = null, $exclude = array(), $ignore_hidden = true)
    {
        if (!is_dir($dir)) {
            return null;
        }

        $files = array();

        foreach (scandir($dir) as $file) {
            if (
                ($file == '.' || $file == '..')
                || ($ignore_hidden && $file{0} == '.')
                || !is_dir("$dir/$file")
                || in_array($file, $exclude)
                || in_array("$dir/$file", $exclude)
            ) {
                continue;
            }

            if (!is_null($filter)) {
                if (!preg_match($filter, $file)) {
                    continue;
                }
            }

            $files[] = rtrim(str_replace($strip_root, '', $dir), '/') ."/$file/";

            if ($recurse) {
                $files = @array_merge($files, self::listDirStructure("$dir/$file", $filter, $recurse, $strip_root, $exclude, $ignore_hidden));
            }
        }

        return $files;
    }
public static function listDirStructure($dir = '.', $filter = null, $recurse = true, $strip_root = null, $exclude = array(), $ignore_hidden = true)
    {
        if (!is_dir($dir)) {
            return null;
        }

        $files = array();

        foreach (scandir($dir) as $file) {
            if (
                ($file == '.' || $file == '..')
                || ($ignore_hidden && $file{0} == '.')
                || !is_dir("$dir/$file")
                || in_array($file, $exclude)
                || in_array("$dir/$file", $exclude)
            ) {
                continue;
            }

            if (!is_null($filter)) {
                if (!preg_match($filter, $file)) {
                    continue;
                }
            }

            $files[] = rtrim(str_replace($strip_root, '', $dir), '/') ."/$file/";

            if ($recurse) {
                $files = @array_merge($files, self::listDirStructure("$dir/$file", $filter, $recurse, $strip_root, $exclude, $ignore_hidden));
            }
        }

        return $files;
    }
public static function listDirStructure ( $ dir = '.' , $ filter = null , $ recurse = true , $ strip_root = null , $ exclude = array ( ) , $ ignore_hidden = true ) { if ( ! is_dir ( $ dir ) ) { return null ; } $ files = array ( ) ; foreach ( scandir ( $ dir ) as $ file ) { if ( ( $ file == '.' || $ file == '..' ) || ( $ ignore_hidden && $ file { 0 } == '.' ) || ! is_dir ( "$dir/$file" ) || in_array ( $ file , $ exclude ) || in_array ( "$dir/$file" , $ exclude ) ) { continue ; } if ( ! is_null ( $ filter ) ) { if ( ! preg_match ( $ filter , $ file ) ) { continue ; } } $ files [ ] = rtrim ( str_replace ( $ strip_root , '' , $ dir ) , '/' ) . "/$file/" ; if ( $ recurse ) { $ files = @ array_merge ( $ files , self :: listDirStructure ( "$dir/$file" , $ filter , $ recurse , $ strip_root , $ exclude , $ ignore_hidden ) ) ; } } return $ files ; }
Construct a multi-dimensional array that reflects the directory
structure of a given path.

@param string $dir (optional)
the path of the directory to construct the multi-dimensional array
for. this defaults to '.'.
@param string $filter (optional)
A regular expression to filter the directories. This is positive filter, ie.
if the filter matches, the directory is included. Defaults to null.
@param boolean $recurse (optional)
true if sub-directories should be traversed and reflected in the
resulting array, false otherwise.
@param mixed $strip_root (optional)
If null, the full path to the file will be returned, otherwise the value
of `strip_root` will be removed from the file path.
@param array $exclude (optional)
ignore directories listed in this array. this defaults to an empty array.
@param boolean $ignore_hidden (optional)
ignore hidden directory (i.e.directories that begin with a period). this defaults
to true.
@return null|array
return the array structure reflecting the input directory or null if
the input directory is not actually a directory.
Construct a multi - dimensional array that reflects the directory structure of a given path .