PHPackages                             dgame/php-iterator - 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. dgame/php-iterator

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

dgame/php-iterator
==================

php iterator

v0.4.0(4y ago)1109.8k↓29.3%11MITPHPPHP ^8.0

Since Aug 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Dgame/php-iterator)[ Packagist](https://packagist.org/packages/dgame/php-iterator)[ Docs](https://github.com/php-iterator)[ RSS](/packages/dgame-php-iterator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (14)Versions (6)Used By (1)

php-iterator
============

[](#php-iterator)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9abc81e75dae9eb718164500151e88041110adb2988586949eecc1ccfccdb3bf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4467616d652f7068702d6974657261746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Dgame/php-iterator/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/ae78586b8d16bdac4573c419e7c8a357f99e23b5fce41a71ed91ad905cff8bf7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4467616d652f7068702d6974657261746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Dgame/php-iterator/?branch=master)[![Build Status](https://camo.githubusercontent.com/67416a2bbec0f413441234c62c1e294f52890293d36877cb4fccdd0badd607eb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4467616d652f7068702d6974657261746f722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Dgame/php-iterator/build-status/master)[![StyleCI](https://camo.githubusercontent.com/3820d72b2a0b87fe4acc59a64140b41ce379e860f9f71133e04b8697215a2558/68747470733a2f2f7374796c6563692e696f2f7265706f732f36313636373639342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/61667694)[![Build Status](https://camo.githubusercontent.com/53bb10853e8462d11c4c19512e51c1c8e96a4cb15d6737b19a13c085745f3ed2/68747470733a2f2f7472617669732d63692e6f72672f4467616d652f7068702d6974657261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Dgame/php-iterator)

Enjoy high order functions
--------------------------

[](#enjoy-high-order-functions)

### only &amp; repeat

[](#only--repeat)

```
$this->assertEquals('aaaa', only('a')->repeat(4)->implode());
```

### take

[](#take)

```
$this->assertEquals('Hal', chars('Hallo')->take(3)->implode());
```

### skip

[](#skip)

```
$this->assertEquals('lo', chars('Hallo')->skip(3)->implode());
```

### slice

[](#slice)

```
$this->assertEquals('oBar', chars('FooBarQuatz')->slice(2, 6)->implode());
```

### chunks

[](#chunks)

```
$this->assertEquals([['F', 'o'], ['o', 'B'], ['a', 'r']], chars('FooBar')->chunks(2)->collect());
```

### fold

[](#fold)

```
$it = iter([6, 7, 8]);

$sum1 = function($sum, int $a) {
    return $sum + $a;
};

$sum2 = function(int $sum, int $a) {
    return $sum + $a;
};

$this->assertEquals(21, $it->fold($sum1));
$this->assertEquals(63, $it->fold($sum2, 42));
```

### take while

[](#take-while)

```
$belowTen = function (int $item) {
    return $item < 10;
};

$this->assertEquals([0, 1, 2], iter([0, 1, 2, 10, 20])->takeWhile($belowTen)->collect());
```

### skip while

[](#skip-while)

```
$belowTen = function (int $item) {
    return $item < 10;
};

$this->assertEquals([10, 20], iter([0, 1, 2, 10, 20])->skipWhile($belowTen)->collect());
```

### before

[](#before)

```
$this->assertEquals('ab', chars('abcdef')->before('c')->implode());
```

```
$this->assertEquals(['a' => 'z', 'b' => 'y'], iter(['a' => 'z', 'b' => 'y', 'c' => 'x', 'd' => 'w'])->before('x')->collect());
```

### after

[](#after)

```
$this->assertEquals('ef', chars('abcdef')->after('d')->implode());
```

```
$this->assertEquals(['d' => 'w'], iter(['a' => 'z', 'b' => 'y', 'c' => 'x', 'd' => 'w'])->after('x')->collect());
```

### from

[](#from)

```
$this->assertEquals('def', chars('abcdef')->from('d')->implode());
```

```
$this->assertEquals(['c' => 'x', 'd' => 'w'], iter(['a' => 'z', 'b' => 'y', 'c' => 'x', 'd' => 'w'])->from('x')->collect());
```

### until

[](#until)

```
$this->assertEquals('abc', chars('abcdef')->until('c')->implode());
```

```
$this->assertEquals(['a' => 'z', 'b' => 'y', 'c' => 'x'], iter(['a' => 'z', 'b' => 'y', 'c' => 'x', 'd' => 'w'])->until('x')->collect());
```

### all

[](#all)

```
$positive = function (int $item) {
    return $item >= 0;
};

$this->assertTrue(iter([0, 1, 2, 3])->all($positive));
$this->assertFalse(iter([-1, 2, 3, 4])->all($positive));
```

### any

[](#any)

```
$positive = function (int $item) {
    return $item > 0;
};

$this->assertTrue(iter([-1, 0, 1])->any($positive));
$this->assertFalse(iter([-1])->any($positive));
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~475 days

Total

5

Last Release

1668d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.0

v0.4.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a9fa98c1a3e70a521430fc2fba266657b2c981b5d8a36bf236fad01f9846dcd?d=identicon)[Dgame](/maintainers/Dgame)

---

Top Contributors

[![Dgame](https://avatars.githubusercontent.com/u/2406877?v=4)](https://github.com/Dgame "Dgame (36 commits)")

---

Tags

functional-programminghigh-orderiteratorphparrayiteratorfilterfunctionaltraversableHigh Order Functions

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dgame-php-iterator/health.svg)

```
[![Health](https://phpackages.com/badges/dgame-php-iterator/health.svg)](https://phpackages.com/packages/dgame-php-iterator)
```

###  Alternatives

[nikic/iter

Iteration primitives using generators

1.1k5.9M38](/packages/nikic-iter)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

381368.5k](/packages/ihor-nspl)[markrogoyski/itertools-php

Iteration tools for PHP

14911.3k](/packages/markrogoyski-itertools-php)[ginq/ginq

LINQ to Object inspired DSL for PHP

192257.5k3](/packages/ginq-ginq)[crell/fp

Functional utilities for PHP 8 and later

91429.8k11](/packages/crell-fp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
