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 登录查看完整内容