mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-27 18:50:43 +00:00
Implement ArrayUtil::arrayRandomIndex()
This commit is contained in:
+14
-1
@@ -136,7 +136,20 @@ class ArrayUtil
|
||||
*/
|
||||
public static function arrayRandom($array)
|
||||
{
|
||||
return $array[mt_rand(0, count($array) - 1)];
|
||||
return $array[static::arrayRandomIndex($array)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Array Random Index
|
||||
*
|
||||
* @access public
|
||||
* @param $array
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function arrayRandomIndex($array)
|
||||
{
|
||||
return mt_rand(0, count($array) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user