I have an array of 8 colors. I want to pick for of those colors randomly. What is the best approach?
array_rand
<?php $color[] = 'blue'; $color[] = 'red'; $color[] = 'yellow'; $color[] = 'black'; $color[] = 'white'; $color[] = 'green'; $numColors = count($color); $x = rand(0, $numColors-1); print "Random color is: ". $color[$x]; ?>