title: PHP readdir() not returning files in alphabetical order
body: <p>I am reading through a directory with some pictures and such using a pretty simple implementation of readdir() like the following:</p>
  
  <pre><code>if ($handle = opendir($path)) {
      while (false !== ($szFilename = readdir($handle))) {
      if ($szFilename[0] !== '.') {
          if (is_file($path.$szFilename)) {
                  // do stuff
              }
          }
       }
   }
  </code></pre>
  
  <p>The problem that I am having is that the files are not being read in alphabetical order as the docs for readdir() state:</p>
  
  <blockquote>
    <p>Returns the filename of the next file
    from the directory. The filenames are
    returned in the order in which they
    are stored by the filesystem.</p>
  </blockquote>
  
  <p>Another weird thing is that, on the local testing server, the same code works great.  This is running on a server using the LAMP stack in both cases.</p>
  
  <p>I know that I can build an array and just sort it, but I was wondering if I was missing something in what I was doing.</p>