title: Faster way to match filename in a folder containing thousend of files
body: <p>I was using this readdir to find a file in a folder  </p>
  
  <pre><code>$handler = opendir($folder);
  
  while ($file = readdir($handler)) {
  
    if ($file != "." &amp;&amp; $file != ".." &amp;&amp; substr($file,0,7) == '98888000') {
      print $file. "&lt;br /&gt;";
    }
  
  }
  </code></pre>
  
  <p>but since I have tons of files in the folder it takes some minutes to complete the request: how can I fast it up?<br>
  Consider I'm on PHP5 + IIS.  </p>
  
  <p>I've tried even glob()</p>
  
  <pre><code>foreach (glob($folder.98888000."*.pdf") as $filename) {
      echo "$filename size " . filesize($filename) . "\n";
  }
  </code></pre>
  
  <p>but it returned nothing.</p>