目录中directorys内的php html文件

I am trying to find all html files within directories in a root directory, I have an array with all the directories in and I'm trying to loop through each directory in the array to find the files and create a list but it is not working, any ideas?

$dirs = glob("/Root_directory*", GLOB_ONLYDIR);

foreach($dirs as $dir) {
    $phpfiles = glob($dir . "*.html");

    foreach($phpfiles as $phpfile) {
        echo "<a href=$phpfile>".basename($phpfile)."</a>";
    }
}

I also tried the approach recommended here using recursion and this gave an empty array

$Directory = new RecursiveDirectoryIterator('path/to/project/');
$Iterator = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($Iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);

This is the recursive method that works after a lot of fiddling.

$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path),        RecursiveIteratorIterator::SELF_FIRST);
$Regex = new RegexIterator($objects, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH);
foreach($Regex as $name => $Rege){
echo "<a href=$name>".$name."</a> 
";
}