nerdexam
Zend

200-550 · Question #166

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.

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

(39 responses)
  • A
    3% (1)
  • B
    10% (4)
  • D
    82% (32)
  • E
    5% (2)

Community Discussion

No community discussion yet for this question.

Full 200-550 Practice