I think you should look at PHP glob
http://php.net/manual/en/function.glob.php
Example : Search dir/module
and sub directory for live.php
or anything that ends with live.php
glob_recursive('dir/module/*live.php');
Function used : http://www.php.net/manual/en/function.glob.php#106595
if ( ! function_exists('glob_recursive'))
{
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;
}
}