Skip to content

Commit

Permalink
Update randomElements to return random number of elements when no c…
Browse files Browse the repository at this point in the history
…ount is provided (#88)
  • Loading branch information
calebdw committed Jun 12, 2023
1 parent 029142a commit f418da3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/formatters/numbers-and-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ echo $faker->randomLetter();

## `randomElements`

Returns `$count` amount of random element from the given array, traversable, or enum. By default, the `$count` parameter is set to 1.
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.

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

// ['c']

echo $faker->randomElements(['a', 'b', 'c', 'd', 'e'], null);

// ['c', 'a', 'e']

echo $faker->randomElements(new \ArrayIterator(['a', 'b', 'c', 'd', 'e']));

// ['c']
Expand Down

0 comments on commit f418da3

Please sign in to comment.