PHP Random Array Element
In PHP, a random array element
can be output using the array_rand function.
This function returns a random key, and
not the element itself, but knowing the key we can get
the value of the element. See the example:
<?php
$arr = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5];
$key = array_rand($arr);
var_dump($key); // random key
var_dump($arr[$key]); // random element
?>