WPDKFilesystem::_rglob PHP Méthode

_rglob() public méthode

Return an array with all matched files from root folder.
public _rglob ( string $path, string $match = '', &$result = [] ) : array
$path string Folder root
$match string Optional. Regex to apply on file name. For example use '/^.*\.(php)$/i' to get only php file
Résultat array
        function _rglob($path, $match = '', &$result = array())
        {
            $files = glob(trailingslashit($path) . '*', GLOB_MARK);
            if (false !== $files) {
                foreach ($files as $file) {
                    if (is_dir($file)) {
                        $continue = apply_filters('wpdk_rglob_find_dir', true, $file);
                        if ($continue) {
                            _rglob($file, $match, $result);
                        }
                    } elseif (!empty($match)) {
                        $continue = apply_filters('wpdk_rglob_find_file', true, $file);
                        if (false == $continue) {
                            break;
                        }
                        $regexp_result = array();
                        $error = preg_match($match, $file, $regexp_result);
                        if (0 !== $error || false !== $error) {
                            $regexp_result = apply_filters('wpdk_rglob_matched', $regexp_result, $file, $match);
                            if (!empty($regexp_result)) {
                                $result[] = $regexp_result[0];
                            }
                        }
                    } else {
                        $result[] = $file;
                    }
                }
                return $result;
            }
        }