Give the function below a shot. It takes two arguments; string Directory and string Extension. It then returns an array of files in that folder with that extension or false on error or no files available.
function list_files($dir, $ext)
{
$rtn = false;
$dir = ($dir{strlen($dir) - 1} == '/' ? substr($dir, 0, -1) : $dir);
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (false !== ($item = readdir($dh))) {
if (is_file($dir . '/' . $item) && preg_match("/\\." . $ext . "$/i", $item)) {
$rtn[] = $item;
}
}
closedir($dh);
}
}
return($rtn);
}
$files = list_files('.', 'html');
print_r($files);