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 arrayCreates 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 )
appendItem( $item , $key = null )
avg( $matcher = null )
cartesianProduct( callable $operation = null , callable $filter = null )
$operation optional null $filter optional null Cake\Collection\CollectionInterfacechunk( $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( )
lazy( )
listNested( $dir = 'desc' , $nestingKey = 'children' )
Cake\Collection\Iterator\TreeIteratormatch( array $conditions )
max( $callback , $type = \SORT_NUMERIC )
median( $matcher = null )
min( $callback , $type = \SORT_NUMERIC )
nest( $idPath , $parentPath , $nestingKey = 'children' )
newCollection( ... $args )
Returns a new collection.
Allows classes which use this trait to determine their own type of returned collection interface
$args Cake\Collection\CollectionInterfaceoptimizeUnwrap( )
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
prepend( $items )
prependItem( $item , $key = null )
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 )
takeLast( $howMany )
through( callable $handler )
toArray( $preserveKeys = true )
toList( )
transpose( )
Cake\Collection\CollectionInterfaceunfold( callable $transformer = null )
unwrap( )
zip( $items )
zipWith( $items , $callable )
cartesianProduct() |
© 2005–present 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.8/class-Cake.Collection.Iterator.ZipIterator.html