alternatively you could try this:
PHP Code:
<?
$array = array('red','yellow','blue','green');
echo $array[ array_rand($array) ];
?>
array_rand() with only the array as an argument will return 1 random key.
the cool thing about the array_rand() function is that it can return more than 1 random key if you give it a second argument. this would be comparable to an sql select statement with a random clause.
so if i wanted 2 random colors from that array, i could do this:
PHP Code:
<?
$array = array('red','yellow','blue','green');
$rand_array_keys = array_rand($array,2);
echo "First Random Color: " . $array[ $rand_array_keys[0] ] . "<br>\n
Second Random Color: " . $array[ $rand_array_keys[1] ];
?>
Might not be that relevant to your situation, but this a way you could assure to grab 2
different random elements from the array.
i forget if it was the sql random, or php random function that didn't always return very random results with a small range of options to choose from.