How can the shuffle() function be used in conjunction with array_rand() to achieve a different outcome when selecting random values from an array in PHP?

When using array_rand() to select random values from an array in PHP, the order of selection may not change between calls. To achieve a different outcome each time, you can use the shuffle() function to randomize the order of the array elements before using array_rand(). This ensures that the selected values will be different each time the code is executed.

$array = [1, 2, 3, 4, 5];
shuffle($array);
$randomValue = array_rand($array);
echo $array[$randomValue];