title: How to exclude certain file types with PHP readdir?
body: <p>I am using a php scan directory script that will scan the contents of a directory and then populate the page with links to the directory contents.</p>
  
  <pre><code>&lt;?php
  $count = 0;
  if ($handle = opendir('.')) {
  while (false !== ($file = readdir($handle))) {
      if ($file != "." &amp;&amp; $file != "..") {$count++;
          print("&lt;a href=\"".$file."\"&gt;".$file."&lt;/a&gt;&lt;br /&gt;\n");
      }
  }
  echo '&lt;br /&gt;&lt;br /&gt;&lt;a href=".."&gt;Return&lt;/a&gt;';
  closedir($handle);
  }
  ?
  </code></pre>
  
  <p>I am wondering how I can exclude certain files or file types like test.xml, durka.xslt or .html from showing up on the populated page. I have some code but not sure how to integrate it. Any help would be very appreciated...</p>
  
  <pre><code>?php
  if ($handle = opendir(‘.’)) {
  while (false !== ($file = readdir($handle)))
  {
  if ($file != “.” &amp;&amp; $file != “..”
  &amp;&amp; $file != “NOT-TO-BE-IN-1.php”
  &amp;&amp; $file != “NOT-TO-BE-IN-2.html”
  &amp;&amp; $file != “NOT-TO-BE-IN-3.jpg”
  &amp;&amp; $file != “”
  &amp;&amp; $file != “”
  &amp;&amp; $file != “”
  &amp;&amp; $file != “”
  &amp;&amp; $file != “”
  
  )
  </code></pre>