I had this piece of code I came up with to load an array of images and then choose one randomly. I have used it on some pages so that people see a different picture when they visit the site.
I want to modify it so that instead of picking a random picture it picks them sequentially. I want to let the user hit f5 to refresh the page and have it pass the next image in the array to the refreshed page.
Example: I am looking at a page with img_2.jpg displayed. I hit F5 for refresh and the page reloads with img_3.jpg. I hit F5 again and the page reloads with img_4.jpg. etc.
Here is the code I have used for the array. How could I modify it so it increments on refresh?
<?php
$picturesArray = array("img_1.jpg", "img_2.jpg",
"img_3.jpg", "img_4.jpg", "img_5.jpg", "img_6.jpg",
"img_7.jpg","img_8.jpg", "img_9.jpg","img_10.jpg",
"img_11.jpg","img_12.jpg", "img_13.jpg","img_14.jpg",
"img_15.jpg");
srand((float) microtime() * 10000000);
shuffle($picturesArray);
echo "<img class=\"main_img\" src=\"../images/comps/$picturesArray[0]\"";
echo " alt=\"Turned My Life Around\" >";
?>
I know a slide show would be more robust, I just need this for a prototyping to let someone see what the page looks like with some of their different pictures, so I don't want to do a slide show.
Thanks for any help.