title: PHP show random images from directory
body: <p>I am kinda new to PHP.</p>
  
  <p>I am searching a way to make PHP showing 6 random JPG images from a directory, no matter what the imagename is. The other important thing is that all the displayed images should be different. </p>
  
  <p>Do you have any idea what's the easiest way to do it?
  I know i should use the glob function, but how to limit the images to 6,random and non repeatable?</p>
  
  <p>I have that as code for the moment:</p>
  
  <pre><code>&lt;?php
      $pictures = glob("images/gallery/*.jpg"); 
      $no_pictures = count($pictures)-1;  
      $limit = $no_pictures-5;            
      for( $i = $no_pictures; $i &gt;= $limit; $i--){ 
      echo '&lt;div class="col-md-4 col-sm-6 col-xs-12 wow fadeInUp"&gt;
              &lt;a class="thumb" href="'.$pictures[$i].'"&gt;&lt;img src="'.$pictures[$i].'" alt="Gallery"/&gt;&lt;span class="thumb_overlay"&gt;&lt;/span&gt;&lt;/a&gt;
            &lt;/div&gt;'; 
  }  
  ?&gt;          
  </code></pre>
  
  <p>But on image refresh it's not displaying different images, it's just tooking random 6 and keep displaying them all the time.</p>