ZipIterator (class)
Class ZipIterator
Creates an iterator that returns elements grouped in pairs
Example
$iterator = new ZipIterator([[1, 2], [3, 4]]); $iterator->toList(); // Returns [[1, 3], [2, 4]]
You can also chose a custom function to zip the elements together, such as doing a sum by index:
Example
$iterator = new ZipIterator([[1, 2], [3, 4]], function ($a, $b) { return $a + $b; }); $iterator->toList(); // Returns [4, 6]
- MultipleIterator implements Iterator, Traversable
- Cake\Collection\Iterator\ZipIterator implements Cake\Collection\CollectionInterface登录查看完整内容