Skip to content

Instantly share code, notes, and snippets.

@wooki
Created July 31, 2012 10:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wooki/3215801 to your computer and use it in GitHub Desktop.
Save wooki/3215801 to your computer and use it in GitHub Desktop.
Util function for a recursive filesearch using glob function
/****************************
*
* Util function for a recursive filesearch using glob function
*
****************************/
if ( ! function_exists('glob_recursive')) {
// Does not support flag GLOB_BRACE
function glob_recursive($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
}
return $files;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment