Problems listing files in a directory/extracting file extensions
<p>I'm attempting to list only jpg files in a directory. There's over 200, but using the code below, only about 100 get listed. I've tried different variations for extracting the file extension, but this has been the only one that's worked: <code>$sub = substr($file, -3);</code></p>

<p>Can anyone tell me why all of the files are not showing up?</p>

<p>Complete source:</p>

<pre><code>&lt;?php
  require('index.inc');
  $page = new buildpage();
  $page-&gt;buildHeader();

   $currentdir = '/home/tim/Documents/Web/';
   $dir = opendir($currentdir);
   echo "&lt;ol&gt;";
   while ($file = readdir($dir)){
      $file = readdir($dir);
      $sub = substr($file, -3);
      $ext = "jpg";
      if (strcasecmp($sub, $ext) == 0) {   
           echo "&lt;li&gt;$file&lt;/li&gt;";
      }
   }
   echo "&lt;/ol&gt;";
?&gt;
</code></pre>
