public function find($base)
    {
        $base = rtrim($base, '/');
        // Special case for a base path of /, eg. a chroot environment
        if ($base === '') {
            $base = '/';
        }

        $paths = array(array($base, 0));
        $found = array();

        $fileCallback = $this->getOption('file_callback');
        $dirCallback  = $this->getOption('dir_callback');

        while ($path = array_shift($paths)) {
            list($path, $depth) = $path;

            foreach (scandir($path) as $basename) {
                if ($basename == '.' || $basename == '..') {
                    continue;
                }

                if (is_dir("$path/$basename")) {
                    if (!$this->acceptDir($basename, "$path/$basename", $depth + 1)) {
                        continue;
                    }

                    if ($dirCallback) {
                        call_user_func(
                            $dirCallback,
                            $basename,
                            "$path/$basename",
                            $depth + 1
                        );
                    }

                    $paths[] = array("$path/$basename", $depth + 1);
                } else {
                    if (!$this->acceptFile($basename, "$path/$basename", $depth)) {
                        continue;
                    }

                    if ($fileCallback) {
                        call_user_func(
                            $fileCallback,
                            $basename,
                            "$path/$basename",
                            $depth
                        );
                    }

                    $found[] = "$path/$basename";
                }
            }
        }

        return $found;
    }
public function find($base)
    {
        $base = rtrim($base, '/');
        // Special case for a base path of /, eg. a chroot environment
        if ($base === '') {
            $base = '/';
        }

        $paths = array(array($base, 0));
        $found = array();

        $fileCallback = $this->getOption('file_callback');
        $dirCallback  = $this->getOption('dir_callback');

        while ($path = array_shift($paths)) {
            list($path, $depth) = $path;

            foreach (scandir($path) as $basename) {
                if ($basename == '.' || $basename == '..') {
                    continue;
                }

                if (is_dir("$path/$basename")) {
                    if (!$this->acceptDir($basename, "$path/$basename", $depth + 1)) {
                        continue;
                    }

                    if ($dirCallback) {
                        call_user_func(
                            $dirCallback,
                            $basename,
                            "$path/$basename",
                            $depth + 1
                        );
                    }

                    $paths[] = array("$path/$basename", $depth + 1);
                } else {
                    if (!$this->acceptFile($basename, "$path/$basename", $depth)) {
                        continue;
                    }

                    if ($fileCallback) {
                        call_user_func(
                            $fileCallback,
                            $basename,
                            "$path/$basename",
                            $depth
                        );
                    }

                    $found[] = "$path/$basename";
                }
            }
        }

        return $found;
    }
public function find ( $ base ) { $ base = rtrim ( $ base , '/' ) ; // Special case for a base path of /, eg. a chroot environment if ( $ base === '' ) { $ base = '/' ; } $ paths = array ( array ( $ base , 0 ) ) ; $ found = array ( ) ; $ fileCallback = $ this -> getOption ( 'file_callback' ) ; $ dirCallback = $ this -> getOption ( 'dir_callback' ) ; while ( $ path = array_shift ( $ paths ) ) { list ( $ path , $ depth ) = $ path ; foreach ( scandir ( $ path ) as $ basename ) { if ( $ basename == '.' || $ basename == '..' ) { continue ; } if ( is_dir ( "$path/$basename" ) ) { if ( ! $ this -> acceptDir ( $ basename , "$path/$basename" , $ depth + 1 ) ) { continue ; } if ( $ dirCallback ) { call_user_func ( $ dirCallback , $ basename , "$path/$basename" , $ depth + 1 ) ; } $ paths [ ] = array ( "$path/$basename" , $ depth + 1 ) ; } else { if ( ! $ this -> acceptFile ( $ basename , "$path/$basename" , $ depth ) ) { continue ; } if ( $ fileCallback ) { call_user_func ( $ fileCallback , $ basename , "$path/$basename" , $ depth ) ; } $ found [ ] = "$path/$basename" ; } } } return $ found ; }
Finds all files matching the options within a directory. The search is
performed depth first.

@param  string $base
@return array
Finds all files matching the options within a directory . The search is performed depth first .