From f418da31ffc146ed8743b1e31b7667d5a2d5e0a4 Mon Sep 17 00:00:00 2001 From: CalebW Date: Mon, 12 Jun 2023 03:40:52 -0500 Subject: [PATCH] Update `randomElements` to return random number of elements when no count is provided (#88) --- docs/formatters/numbers-and-strings.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/formatters/numbers-and-strings.md b/docs/formatters/numbers-and-strings.md index 24fcae11..2b57248f 100644 --- a/docs/formatters/numbers-and-strings.md +++ b/docs/formatters/numbers-and-strings.md @@ -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']