What is the purpose of using array_rand() in PHP and what does it return?

The array_rand() function in PHP is used to randomly select one or more keys from an array. This can be useful when you want to retrieve a random element from an array or shuffle the elements in an array. The function returns one or more random keys from the array.

// Example of using array_rand() to select a random element from an array
$colors = array("red", "blue", "green", "yellow", "orange");
$random_color_key = array_rand($colors);
$random_color = $colors[$random_color_key];
echo "Random color: " . $random_color;