PHP: Return a random element from an array
Getting a random element from a PHP array is a multi-step process and I often forget the syntax. Here is a simple function that will return a random element from the provided array.
function random_elem(array $arr) {
$key = array_rand($arr);
$ret = $arr[$key];
return $ret;
}