Merge pull request #732 from zachborboa/master

Implement ArrayUtil::arrayRandomIndex()
This commit is contained in:
Zach Borboa
2022-09-28 14:19:02 -07:00
committed by GitHub
2 changed files with 15 additions and 2 deletions
+14 -1
View File
@@ -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);
}
/**
+1 -1
View File
@@ -146,7 +146,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
*
* @param void
*
* @return int The number of elements stored in the array.
* @return integer The number of elements stored in the array.
*
* @access public
*/