Skip to content

Commit 67c3769

Browse files
committed
...
1 parent b3ed320 commit 67c3769

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ArrayFunctions.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ function slice(array $array, $offset = 0, $limit = 0)
127127
*/
128128
function random(array $array)
129129
{
130-
$index = NumberFunctions\random(0, length($array) - 1);
131-
132-
if (isset($array[$index])) {
133-
return $array[$index];
130+
if (length($array) === 0) {
131+
return null;
134132
}
135133

136-
return null;
134+
$index = NumberFunctions\random(0, length($array) - 1);
135+
136+
return $array[$index];
137137
}

0 commit comments

Comments
 (0)