note 106872 deleted from function.array-rand by danbrown
| From: | danbrown@php.net | Date: | Tue, 03 Jan 2012 22:12:36 +0000 |
| Subject: | note 106872 deleted from function.array-rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185333@lists.php.net to get a copy of this message | ||
Note Submitter: php at kingsquare dot nl
----
In follow up of Anonymous 02-Oct-2009 10:04 this is a faster method of doing the same thing:
if (!function_exists('array_rand_value')) {
/**
* Return a random value out of an array
* @param array $array
* @return mixed
*/
function array_rand_value($array) {
return $array[array_rand($array, 1)];
}
}