Skip to content

Commit f418da3

Browse files
authored
Update randomElements to return random number of elements when no count is provided (#88)
1 parent 029142a commit f418da3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/formatters/numbers-and-strings.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ echo $faker->randomLetter();
9292

9393
## `randomElements`
9494

95-
Returns `$count` amount of random element from the given array, traversable, or enum. By default, the `$count` parameter is set to 1.
95+
Returns `$count` amount of random element from the given array, traversable, or enum. By default, the `$count` parameter is set to 1, when `null` a random number of elements is returned.
9696

9797
```php
9898
echo $faker->randomElements(['a', 'b', 'c', 'd', 'e']);
9999

100100
// ['c']
101101

102+
echo $faker->randomElements(['a', 'b', 'c', 'd', 'e'], null);
103+
104+
// ['c', 'a', 'e']
105+
102106
echo $faker->randomElements(new \ArrayIterator(['a', 'b', 'c', 'd', 'e']));
103107

104108
// ['c']

0 commit comments

Comments
 (0)