php random images with known names and locations


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $images = array(1=>1, 2, 3, 4, 5);
  3. for ($i= 0; $i < 3; $i++) {
  4. $nr[$i] = array_rand($images,1);
  5. unset($images[$nr[$i]]);
  6. ?>
  7. <img src="http://images_path/imagename_<?php echo $nr[$i] ?>.png" width='image_width' height='image_height' alt='image_alt_text' />
  8. <?php
  9. }
  10. ?>
  11.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.