Creates an iterator that returns elements grouped in pairs
$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:
$iterator = new ZipIterator([[1, 2], [3, 4]], function ($a, $b) { return $a + $b; }); $iterator->toList(); // Returns [4, 6]
MIT_KEYS_ASSOC
, MIT_KEYS_NUMERIC
, MIT_NEED_ALL
, MIT_NEED_ANY
$_callback
protected callable
$_iterators
protected array
Creates the iterator to merge together the values by for all the passed iterators by their corresponding index.
Returns the value resulting out of zipping all the elements for all the iterators with the same positional index.
Returns a string representation of this object that can be used to reconstruct it
__construct( array $sets , callable|null $callable null )
Creates the iterator to merge together the values by for all the passed iterators by their corresponding index.
$sets
$callable
optional null MultipleIterator::__construct()
current( )
Returns the value resulting out of zipping all the elements for all the iterators with the same positional index.
MultipleIterator::current()
Iterator::current()
serialize( )
Returns a string representation of this object that can be used to reconstruct it
Serializable::serialize()
unserialize( string $iterators )
Unserializes the passed string and rebuilds the ZipIterator instance
$iterators
Serializable::unserialize()
_unwrap( )
append( $items )
cartesianProduct( callable $operation null , callable $filter null )
Cake\Collection\CollectionInterface
chunk( $chunkSize )
chunkWithKeys( $chunkSize , $preserveKeys true )
combine( $keyPath , $valuePath , $groupPath null )
compile( $preserveKeys true )
contains( $value )
countBy( $callback )
each( callable $c )
every( callable $c )
extract( $matcher )
first( )
firstMatch( array $conditions )
groupBy( $callback )
indexBy( $callback )
isEmpty( )
jsonSerialize( )
last( )
listNested( $dir 'desc' , $nestingKey 'children' )
Cake\Collection\Iterator\TreeIterator
match( array $conditions )
max( $callback , $type SORT_NUMERIC )
min( $callback , $type SORT_NUMERIC )
nest( $idPath , $parentPath , $nestingKey 'children' )
reduce( callable $c , $zero null )
sample( $size 10 )
shuffle( )
skip( $howMany )
some( callable $c )
sortBy( $callback , $dir SORT_DESC , $type SORT_NUMERIC )
sumOf( $matcher null )
take( $size 1 , $from 0 )
through( callable $handler )
toArray( $preserveKeys true )
toList( )
unfold( callable $transformer null )
unwrap( )
zip( $items )
zipWith( $items , $callable )
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.Collection.Iterator.ZipIterator.html