Firstly, we create an array of images. This can be any amount of images, it doesn't matter.
- Code: Select all
$images = array("image1.png", "image2.png", "image3.png");
Now we use the shuffle() function to select a random value from the array and return it.
- Code: Select all
$value = shuffle($images);
Then we just echo out the image using the $value variable as the src.
- Code: Select all
echo '<img src="' . $value . '" alt="Image" />';
Thanks for reading, I hope it helped.
