What could be causing issues with displaying images on a webpage when using PHP to select them randomly?

The issue could be related to how the images are being selected randomly in the PHP code. To solve this issue, make sure that the random selection of images is done correctly and that the file paths are accurate.

<?php
$images = array("image1.jpg", "image2.jpg", "image3.jpg");

// Select a random image from the array
$randomImage = $images[array_rand($images)];

// Display the selected image
echo "<img src='images/$randomImage' alt='Random Image'>";
?>