title: opendir array exclude file from results
body: <p>The code below will select all of my php files from the named folder and then shuffle them and echo 10 results on my page, the folder contains an index.php file which i would like to be excluded from the results.</p>
  
  <pre><code>&lt;?php 
  
  if ($handle = opendir('../folder/')) {
      $fileTab = array();
      while (false !== ($file = readdir($handle))) {
          if ($file != "." &amp;&amp; $file != "..") {
              $fileTab[] = $file;
          }
      }
      closedir($handle);
      shuffle($fileTab);
      foreach(array_slice($fileTab, 0, 10) as $file) {
          $title = str_replace('-', ' ', pathinfo($file, PATHINFO_FILENAME));
          $thelist .= '&lt;p&gt;&lt;a href="../folder/'.$file.'"&gt;'.$title.'&lt;/a&gt;&lt;/p&gt;';
      }
  }
  ?&gt;
  &lt;?=$thelist?&gt;
  </code></pre>
  
  <p>I have found a code to exclude index.php but I'm not sure how to incorporate it into my code above.</p>
  
  <pre><code>&lt;?php
  $random = array_values( preg_grep( '/^((?!index.php).)*$/', glob("../folder/*.php") ) );
  $answer = $random[mt_rand(0, count($random) -1)];
  include ($answer);
  ?&gt; 
  </code></pre>