I have a code that lists all of the files and folders in a directory. What I can't figure out is how to exclude certain files based on a list of values in an array. For instance, I have an array like the one below. I want to reference this list and exclude any item that contains one of those substrings:
$hideDir = array('.php', '.html', '.css');
Here's my current loop. Any thoughts on what I'm doing wrong?
echo '<ul>';
foreach($hideDir as $v) {
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if (strpos($entry, $v) > -1) {
//do nothing
}else{
echo '<li>' . "$entry" . '</li>' . "
";
}
}
}
closedir($handle);
}
echo '</ul>';