/code/php/functions/rglob.php
PHP | 32 lines | 12 code | 2 blank | 18 comment | 1 complexity | 99abf41c669170b3f671f477c5f6bae0 MD5 | raw file
- <?php
- /**
- * Recursive glob()
- *
- * @link http://php.net/glob
- * @author HM2K <hm2k@php.net>
- * @version $Revision: 1.2 $
- * @require PHP 4.3.0 (glob)
- */
-
- /**
- * @param int $pattern
- * the pattern passed to glob()
- * @param int $flags
- * the flags passed to glob()
- * @param string $path
- * the path to scan
- * @return mixed
- * an array of files in the given path matching the pattern.
- */
-
- function rglob($pattern='*', $flags = 0, $path=false)
- {
- if (!$path) { $path=dirname($pattern).DIRECTORY_SEPARATOR; }
- $pattern=basename($pattern);
- $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
- $files=glob($path.$pattern, $flags);
- foreach ($paths as $path) {
- $files=array_merge($files,rglob($pattern, $flags, $path));
- }
- return $files;
- }