title: Limit Max Results after glob sort by time
body: <p>I'd like to limit the results returned after I glob the files in a directory and sort them by time. And just in case there are no files in the directory, I'd like to include an <code>if file exists</code> phrase as well. Here is the code so far.</p>
  
  <pre><code>$list = glob('items/*.html');
  usort(
     $list,
     create_function('$a,$b', 'return filemtime($a) &lt; filemtime($b);')
  );
  
  
  foreach($list as $file)
  {
      include $file;
  }
  </code></pre>
  
  <p>Now I'm guessing, I can probably do the <code>if (file_exists())</code> part like this:</p>
  
  <pre><code>foreach($list as $file)
  {
   if (file_exists($file)) {
      include $file;}
  }
  </code></pre>
  
  <p>part without throwing errors, but where do I do the count up to a max of 5 or 7?</p>