1. Go to this page and download the library: Download dutekvejin/iterators library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dutekvejin / iterators example snippets
php
use Dutek\Iterator\ChunkIterator;
$iterator = new \ArrayIterator([1, 2, 3, 4, 5]);
$size = 2;
$chunkIterator = new ChunkIterator($iterator, $size);
assert(iterator_to_array($chunkIterator) === [[1, 2], [3, 4], [5]]);
php
use Dutek\Iterator\MapIterator;
$iterator = new \ArrayIterator([1, 2, 3, 4, 5]);
$callback = function (int $item) {
return $item ** 2;
};
$mapIterator = new MapIterator($iterator, $callback);
assert(iterator_to_array($mapIterator) === [1, 4, 9, 16, 25]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.