Posted By

ryarwood on 06/09/11


Tagged

php random loop images lyon


Versions (?)

Random Start Image Loop


 / Published in: PHP
 

  1. <?php
  2. $imgString = "/images/elements/gallery-{url_title}-";
  3. $imgGallery = range(1, {community-gallery} + 1);
  4. $i = $start = mt_rand(1, {community-gallery});
  5. do {
  6. if ($i != 0) {
  7. echo '<img src="'.$imgString.$i.'.jpg" width="730" height="340" />';
  8. }
  9. $i = ($i + 1) % count($imgGallery);
  10. } while ($i != $start);
  11. ?>

Report this snippet  

You need to login to post a comment.