Skip to content

Instantly share code, notes, and snippets.

@deniscsz
Forked from wooki/php_glob
Created October 24, 2015 13:56
Show Gist options
  • Save deniscsz/3c38d0f1b99fd8cf1922 to your computer and use it in GitHub Desktop.
Save deniscsz/3c38d0f1b99fd8cf1922 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