Skip to content

Instantly share code, notes, and snippets.

@dol
Last active August 29, 2015 14:06
Show Gist options
  • Save dol/ae2c6284e7a691f10313 to your computer and use it in GitHub Desktop.
Save dol/ae2c6284e7a691f10313 to your computer and use it in GitHub Desktop.
<?php
$content = <<<'EOF'
Line 1
Line 2
Line 3
Line 4
EOF;
$tmpCsvFile = new SplTempFileObject();
$tmpCsvFile->fwrite($content);
$iterator = new CallbackFilterIterator($tmpCsvFile, function ($row) {
return true;
});
echo 'Limit 2: ', iterator_count(new LimitIterator($iterator, 2)), ' ', iterator_count(new LimitIterator($tmpCsvFile, 2)), "\n";
echo 'Limit 3: ', iterator_count(new LimitIterator($iterator, 3)), ' ', iterator_count(new LimitIterator($tmpCsvFile, 3)), "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment