What are some best practices for implementing a random image/text feature on a website using PHP?

To implement a random image/text feature on a website using PHP, you can create an array of images/texts and use the `array_rand()` function to select a random element from the array. Then, you can display the randomly selected image/text on the website.

<?php
// Array of images/texts
$randomItems = [
    "image1.jpg",
    "image2.jpg",
    "image3.jpg",
    "text1",
    "text2",
    "text3"
];

// Select a random item from the array
$randomItem = $randomItems[array_rand($randomItems)];

// Display the randomly selected image/text
if (strpos($randomItem, 'jpg') !== false) {
    echo '<img src="' . $randomItem . '" alt="Random Image">';
} else {
    echo '<p>' . $randomItem . '</p>';
}
?>