Skip to content

Instantly share code, notes, and snippets.

@gavinhewitt
Forked from wooki/php_glob
Created August 24, 2016 19:25
Show Gist options
  • Save gavinhewitt/264b50085acfb37ea4991ddeddf94f64 to your computer and use it in GitHub Desktop.
Save gavinhewitt/264b50085acfb37ea4991ddeddf94f64 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