Skip to content

Instantly share code, notes, and snippets.

@jfcherng
Last active August 29, 2015 14:25
Show Gist options
  • Save jfcherng/e45f6d29c8af3f1b3ce3 to your computer and use it in GitHub Desktop.
Save jfcherng/e45f6d29c8af3f1b3ce3 to your computer and use it in GitHub Desktop.
Recursive glob() for PHP 5.
function recuresive_glob ($dir, $regex) {
$dirIt = new RecursiveDirectoryIterator($dir);
$itIt = new RecursiveIteratorIterator($dirIt);
$files = new RegexIterator($itIt, $regex, RegexIterator::GET_MATCH);
$fileList = array();
foreach ($files as $file) {
$fileList[] = $file[0];
}
return $fileList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment