PHPackages                             nikic/iter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nikic/iter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nikic/iter
==========

Iteration primitives using generators

v2.4.1(2y ago)1.1k5.9M↑11.6%69[9 issues](https://github.com/nikic/iter/issues)[6 PRs](https://github.com/nikic/iter/pulls)20BSD-3-ClausePHPPHP &gt;=7.1CI passing

Since Jan 1Pushed 9mo ago34 watchersCompare

[ Source](https://github.com/nikic/iter)[ Packagist](https://packagist.org/packages/nikic/iter)[ RSS](/packages/nikic-iter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (15)Used By (20)

Iteration primitives using generators
=====================================

[](#iteration-primitives-using-generators)

This library implements iteration primitives like `map()` and `filter()`using generators. To a large part this serves as a repository for small examples of generator usage, but of course the functions are also practically quite useful.

All functions in this library accept arbitrary iterables, i.e. arrays, traversables, iterators and aggregates, which makes it quite different from functions like `array_map()` (which only accept arrays) and the SPL iterators (which usually only accept iterators, not even aggregates). The operations are of course lazy.

Install
-------

[](#install)

To install with composer:

```
composer require nikic/iter
```

Functionality
-------------

[](#functionality)

A small usage example for the `map()` and `range()` functions:

```
