Multiple choice general knowledge

Which of the function is used to pick up one or more random values from the PHP array?

  1. array_random()

  2. Rand_array()

  3. Random_array()

  4. array_rand()

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

array_rand() is the correct PHP function that picks one or more random entries from an array. It returns the key(s) of random value(s), not the values themselves. By default it returns one random key, or you can pass a second parameter to get multiple random keys. The other options are not valid PHP functions.