How to exclude file extensions when searching files in a folder
<p>I would like to know how I can implement an "exclude" extensions function.</p>

<p>For example, I would like to search a folder with the "gif", "jpg", and "png" extensions, but not "php", "shtml", "htm" and echo the results.</p>

<p>I have .php and .shtml files in the same folder that need to be in there and want to exclude those extensions.</p>

<p>Here is my present code: </p>

<pre><code>$intFileCount = countFilesInDirectory('/user/fred/photos', array('jpg','gif','png'));
echo $intFileCount;

function countFilesInDirectory($strPathToDirectory, $arrExtensions) {
$intFileCount = 0;
$arrFiles = scandir($strPathToDirectory);

foreach($arrFiles as $strFile) {
if('.' != $strFile &amp;&amp; '..' != $strFile) {
if(is_dir("$strPathToDirectory/$strFile") &amp;&amp; is_readable("$strPathToDirectory/$strFile")) {
$intFileCount += countFilesInDirectory("$strPathToDirectory/$strFile", $arrExtensions);

} else {
$arrFileInfo = pathinfo($strFile);
if(in_array($arrFileInfo['extension'], $arrExtensions)) {
$intFileCount += 1;
}
     }
  }
}

return $intFileCount;
}
</code></pre>

<p>My actual/original intent for the script is that I want it (my script) to count the files inside a folder where "videos" were uploaded to a folder and the extensions for those (videos) are far too vast to filter out .MP3 .MP4 .MOV .MPG .FLV etc and countless others.</p>
