What is the purpose of using array_rand() in the given PHP code?

The purpose of using array_rand() in the given PHP code is to select a random key from an array. This function can be useful when you want to randomly select an element from an array without having to shuffle the entire array.

// Original code snippet
$colors = array("Red", "Green", "Blue", "Yellow");
$random_color = $colors[array_rand($colors)];
echo "Random color: " . $random_color;