PHP code example of xenira / iter-tools
1. Go to this page and download the library: Download xenira/iter-tools 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/ */
xenira / iter-tools example snippets
$iterator = new ArrayIterator([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
$iterator = $iterator
->filter(fn ($value) => $value % 2 === 0)
->map(fn ($value) => $value * 2)
->take(4);
assert($iterator->collect() === [4, 8, 12, 16]);