Skip to content

Commit 067cb72

Browse files
committed
Implement ArrayUtil::arrayRandomIndex()
1 parent 7ce0fc5 commit 067cb72

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Curl/ArrayUtil.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,20 @@ public static function array_flatten_multidim($array, $prefix = false)
136136
*/
137137
public static function arrayRandom($array)
138138
{
139-
return $array[mt_rand(0, count($array) - 1)];
139+
return $array[static::arrayRandomIndex($array)];
140+
}
141+
142+
/**
143+
* Array Random Index
144+
*
145+
* @access public
146+
* @param $array
147+
*
148+
* @return integer
149+
*/
150+
public static function arrayRandomIndex($array)
151+
{
152+
return mt_rand(0, count($array) - 1);
140153
}
141154

142155
/**

src/Curl/CaseInsensitiveArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function offsetGet($offset)
146146
*
147147
* @param void
148148
*
149-
* @return int The number of elements stored in the array.
149+
* @return integer The number of elements stored in the array.
150150
*
151151
* @access public
152152
*/

0 commit comments

Comments
 (0)