Hello.
I'm having difficulty getting the array_rand function to work. The example for the array_rand function in the PHP Manual calls two values. If I change the example to try to get only one variable it doesn't output anything.
http://us2.php.net/manual/en/function.array-rand.php
// This is the example in the PHP Manual
// It outputs two values
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2); // Tells it to output 2 values
echo $input[$rand_keys[0]] . "<br>\n";
echo $input[$rand_keys[1]] . "<br>\n";
// This should output one value but it doesn not output anything.
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 1); // Change this to one
echo $input[$rand_keys[0]] . "<br>\n";
echo $input[$rand_keys[1]] . "<br>\n";
Can anybody see what I'm doing wrong?
Thanks.