PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/code/php/functions/rglob.php

http://hm2k.googlecode.com/
PHP | 32 lines | 12 code | 2 blank | 18 comment | 1 complexity | 99abf41c669170b3f671f477c5f6bae0 MD5 | raw file
  1. <?php
  2. /**
  3. * Recursive glob()
  4. *
  5. * @link http://php.net/glob
  6. * @author HM2K <hm2k@php.net>
  7. * @version $Revision: 1.2 $
  8. * @require PHP 4.3.0 (glob)
  9. */
  10. /**
  11. * @param int $pattern
  12. * the pattern passed to glob()
  13. * @param int $flags
  14. * the flags passed to glob()
  15. * @param string $path
  16. * the path to scan
  17. * @return mixed
  18. * an array of files in the given path matching the pattern.
  19. */
  20. function rglob($pattern='*', $flags = 0, $path=false)
  21. {
  22. if (!$path) { $path=dirname($pattern).DIRECTORY_SEPARATOR; }
  23. $pattern=basename($pattern);
  24. $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
  25. $files=glob($path.$pattern, $flags);
  26. foreach ($paths as $path) {
  27. $files=array_merge($files,rglob($pattern, $flags, $path));
  28. }
  29. return $files;
  30. }