// Array of strings that "disqualify" files.
$excluded = array('indexer2.php', '.html', '.php', 'TN_');
// Read the directory.
while ($file = readdir($dir)) {
// echo by default.
$echo_file = true;
// Loop through unwanted strings.
foreach ($excluded as $value) {
// Check each file for unwanted string; strtolower() covers all.
if (strpos(strtolower($file), strtolower($value)) !== false) {
// If unwanted string found, don't echo the file.
$echo_file = false;
// One false is all we need.
break;
}
}
// Now check to see if the file is flagged, etc.
if (($echo_file != false) && ($file != '.') && ($file != '..')) {
// If everything is ok, echo the file.
echo '<a href="' . $file . '">' . $file . '</a><br />';
}
}