AppserverIo\Appserver\Core\Utilities\FileSystem::globDir PHP Метод

globDir() публичный статический Метод

Parses and returns the directories and files that matches the passed glob pattern in a recursive way (if wanted).
public static globDir ( string $pattern, integer $flags, boolean $recursive = true ) : array
$pattern string The glob pattern used to parse the directories
$flags integer The flags passed to the glob function
$recursive boolean Whether or not to parse directories recursively
Результат array The directories matches the passed glob pattern
    public static function globDir($pattern, $flags = 0, $recursive = true)
    {
        // parse the first directory
        $files = glob($pattern, $flags);
        // parse all subdirectories, if recursive parsing is wanted
        if ($recursive !== false) {
            foreach (glob(dirname($pattern) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR | GLOB_NOSORT | GLOB_BRACE) as $dir) {
                $files = array_merge($files, FileSystem::globDir($dir . DIRECTORY_SEPARATOR . basename($pattern), $flags));
            }
        }
        // return the array with the files matching the glob pattern
        return $files;
    }

Usage Example

 /**
  * Parses and returns the directories and files that matches
  * the passed glob pattern in a recursive way (if wanted).
  *
  * @param string  $pattern   The glob pattern used to parse the directories
  * @param integer $flags     The flags passed to the glob function
  * @param boolean $recursive Whether or not to parse directories recursively
  *
  * @return array The directories matches the passed glob pattern
  * @link http://php.net/glob
  */
 protected static function globDir($pattern, $flags = 0, $recursive = true)
 {
     return FileSystem::globDir($pattern, $flags, $recursive);
 }
All Usage Examples Of AppserverIo\Appserver\Core\Utilities\FileSystem::globDir