Download the PHP package suramon/itertools without Composer
On this page you can find all versions of the php package suramon/itertools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download suramon/itertools
More information about suramon/itertools
Files in suramon/itertools
Package itertools
Short Description Iterators implemented in PHP, copy-pasted from Python
License MIT
Homepage https://github.com/SuRaMoN/itertools
Informations about the package itertools
itertools
A set of iterators for PHP based on pythons itertools.
Some iterator examples
Install Guide
Manual Install
- Download itertools directly from GitHub, or clone it with Git:
git clone https://github.com/SuRaMoN/relike.git
- Include the autoload header located in
src/autload.php
(eg:require 'relike/src/autoload.php';
) or you can use psr-0 - Learn and use itertools by looking at the examples, tests and source code
Some iterators explained
ChainIterator
Iterator equivalent of flattening a 2-dimensional array.
ChunkingIterator
Splits a iterator into smaller chunks. this can be used for batch processing.
ForkingIterator
This linux-only iterator is designed to be iterated by a foreach loop and forks a new process for each iteration.
HistoryIterator
An iterator that keeps track of the elements it iterates. It differs from the CachingIterator in the standard PHP library because this implementations allows the history size to be specified.
MapIterator
Iterator equivalent or array_map.
SliceIterator
Iterator equivalent of array_slice.
$lines = new SliceIterator(new FileLineIterator('file.txt'), 0, 1000); // will iterate the first 1000 lines of the file
UniqueIterator
Iterator equivalent of array_unique but only works for sorted input.
RangeIterator
Iterator equivalent of range.
ZipIterator
Inspired by pythons zip function. It can be constructed with an array of iterators and it iterates all of its arguments at the same index, returning during each iteration an array of the elements of each iterator on the same iteration positon