Php random images

php scripts anvar in

This is a script to print random 10 images. You can simply change this to 20 or 100 images.

Applicable level : When you have a website with your portfolio always  showing the same portfolio but when you use this script your work will be changed in each reload.

PHP Script:

<?php 
 $len = 10;$min = 0;$max = 9;
 $range = array();
 foreach (range(0, $len - 1) as $i) {
 while(in_array($num = mt_rand($min, $max), $range));
 $range[] = $num;} 
 for ($x = 0; $x <=9; $x++) {
 ?>

Working Demo:

<div class="container padBot">
 <div class="row">
   <section class="span12">
     <h2 class="margBot2">Anvar Work</h2>
        <div class="row"> 
           <?php 
             $len = 10;$min = 0;$max = 9;
             $range = array();
             foreach (range(0, $len - 1) as $i) {
             while(in_array($num = mt_rand($min, $max), $range));
             $range[] = $num;} 
             for ($x = 0; $x <=9; $x++) {
           ?> 
      <article class="span4 box4">
         <div class="thumb-pad4 maxheight">
           <div class="thumbnail">
            <figure>
               <a href='gypsum/gypsum-0<?php echo $range[$x] ?>.jpg'>
                   <img src="gypsum/gypsumthumb-0<?php echo $range[$x] ?>.jpg" alt="">
               </a>
            </figure>
          <div class="caption">
         <p>Anvar Work </p>
       </div>
       </div>
     </div>
      </article>
  <?php } ?> 
 </div>
 </section>
 </div>
 </div>