I wrote a function similar to your needs not long ago:
private function getFilesByPattern($pattern = '*.html', $flags = 0){ $files = glob($pattern, $flags); foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { $files = array_merge($files, $this->getTestFiles($dir . '/' . basename($pattern), $flags)); } return $files;}
This function also searches recusively through sub directories! For $flags
look into the flags of glob: http://php.net/manual/de/function.glob.php
Can be called like this: getTestFiles('../src/directory/*.html')