Skip to content

Commit 0fc2cd1

Browse files
committed
doc: update
1 parent 1e5f3af commit 0fc2cd1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This package provides functions to work with [iterables](https://wiki.php.net/rf
1616
- [iterable_reduce()](#iterable_reduce)
1717
- [iterable_filter()](#iterable_filter)
1818
- [iterable_values()](#iterable_values)
19+
- [iterable_chunk()](#iterable_chunk)
1920

2021
iterable_to_array()
2122
-------------------
@@ -170,6 +171,33 @@ foreach (iterable_values($generator()) as $key => $value) {
170171
}
171172
```
172173

174+
iterable_chunk()
175+
--------------
176+
177+
Here's an `array_chunk`-like function that also works with a `Traversable`.
178+
179+
```php
180+
use function BenTools\IterableFunctions\iterable_chunk;
181+
182+
$fruits = [
183+
'banana',
184+
'apple',
185+
'strawberry',
186+
'raspberry',
187+
'pineapple',
188+
]
189+
$fruits = (fn () => yield from $fruits)()
190+
iterable_chunk($fruits, 2);
191+
192+
/*
193+
[
194+
['banana', 'apple'],
195+
['strawberry', 'raspberry'],
196+
['pineapple'],
197+
]
198+
*/
199+
```
200+
173201
Iterable fluent interface
174202
=========================
175203

0 commit comments

Comments
 (0)