I hate PHP’s array_rand() function
https://marco.org/2007/09/17/i-hate-phps-array-rand-function
…so I made a handy util function to do what I really want:
// Does what array_rand() should do: // returns the VALUES instead of the keys. function array_return_rand($input, $num_req = 1) { $keys = array_rand($input, $num_req); if ($num_req == 1) { return $input[$keys]; } else { $out_array = array(); foreach ($keys as $k) $out_array[$k] = $input[$k]; return $out_array; } }