How can a specific value from an array be randomly output in PHP?

To output a specific value from an array randomly in PHP, you can use the array_rand() function. This function returns a random key from the array, which you can then use to access the corresponding value.

<?php
// Define an array
$values = array("Apple", "Banana", "Orange", "Grape", "Pineapple");

// Get a random key from the array
$randomKey = array_rand($values);

// Output the corresponding value
echo $values[$randomKey];
?>