Zend
200-710 · Question #188
Which of the following expressions will evaluate to a random value from an array below? $array = array("Sue", "Mary", "John", "Anna");
The correct answer is D. $array[array_rand($array)]. See the full explanation below for the reasoning.
Arrays
Question
Which of the following expressions will evaluate to a random value from an array below?
$array = array("Sue", "Mary", "John", "Anna");Options
- Aarray_rand($array);
- Barray_rand($array, 1);
- Cshuffle($array);
- D$array[array_rand($array)];
- Earray_values($array, ARRAY_RANDOM);
How the community answered
(34 responses)- A6% (2)
- B3% (1)
- C9% (3)
- D82% (28)
Topics
#array_rand#random access#array indexing#shuffle
Community Discussion
No community discussion yet for this question.