Random image script from a directory
<p>Can someone please assist me. I found this script on stackoverflow, but need to modify it to only show 8 random (non repetitive) images, and keep failing. Whatever I try throws an error and after an hour I'm at a loss...</p>

<pre><code>   $dir = 'Albums/Kids/S/';
   $file_display = array ('jpg', 'jpeg', 'png', 'gif');
   $dir_contents = scandir($dir);
   shuffle($dir_contents);
   foreach ($dir_contents as $file) {
      $file_type = strtolower(end(explode('.', $file)));
      if ($file !== '.' &amp;&amp; $file !== '..' &amp;&amp; in_array($file_type, $file_display) == true) {
         $thumbs .= '&lt;img src="'.$dir.'/'.$file.'" alt="" /&gt;';
      }
   }
</code></pre>
