Find all files with specific extensions in directroy and subdirectories
<?php
$extension = 'php';
$folder = 'folder';
if(file_exists($folder)) {
$dir = new RecursiveDirectoryIterator($folder);
foreach (new RecursiveIteratorIterator($dir) as $filename => $file) {
if ($file->isFile() && $file->getExtension() == $extension) {
echo $file->getPathname() . "<br />";
}
}
} else {
echo 'folder not found';
}
?>