PHPackages                             domwebber/array-toggle-permutations - 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. domwebber/array-toggle-permutations

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

domwebber/array-toggle-permutations
===================================

PHP array permutations iterator. A simple way to loop through every possible combination of items in an array.

v1.0.2(4y ago)06GPL-3.0-or-laterPHP

Since Jul 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/domwebber/array-toggle-permutations)[ Packagist](https://packagist.org/packages/domwebber/array-toggle-permutations)[ RSS](/packages/domwebber-array-toggle-permutations/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

PHP Array Permutations Iterator
===============================

[](#php-array-permutations-iterator)

[![PRs Welcome](https://camo.githubusercontent.com/7d9ed3c8f22eceb1711573169b1390cc0b1194467340dc815205060c162b5309/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](http://makeapullrequest.com)[![Latest Stable Version](https://camo.githubusercontent.com/cf20d28389e02093e17d9340cd3e46945b29b07cab25b27b06b53bca460e0280/687474703a2f2f706f7365722e707567782e6f72672f646f6d7765626265722f61727261792d746f67676c652d7065726d75746174696f6e732f76)](https://packagist.org/packages/domwebber/array-toggle-permutations)[![Total Downloads](https://camo.githubusercontent.com/45f91bf57940ef95e0e7abd02fd9746a8f0016310a102edf44e85d2ef859b0ae/687474703a2f2f706f7365722e707567782e6f72672f646f6d7765626265722f61727261792d746f67676c652d7065726d75746174696f6e732f646f776e6c6f616473)](https://packagist.org/packages/domwebber/array-toggle-permutations)[![License](https://camo.githubusercontent.com/9134aef5e4f8c5690a6db233e2af6037e8b59b9914730bea5f7ca8b51ae6fe69/687474703a2f2f706f7365722e707567782e6f72672f646f6d7765626265722f61727261792d746f67676c652d7065726d75746174696f6e732f6c6963656e7365)](https://packagist.org/packages/domwebber/array-toggle-permutations)

A helpful PHP utility that easily loops through every possible combination of array items. This package is intended for use in testing environments but is unit tested to the degree that it is also safe for use in a production environment too (within reason).

Installation
------------

[](#installation)

Use the [composer](https://getcomposer.org) package manager to install the Array Permutations Iterator.

```
composer require domwebber/array-toggle-permutations
```

Usage
-----

[](#usage)

This library can be used to toggle the options of a numerically-indexed array or an associative array. In the case where an associative array is used, the array keys will be maintained. In either case, the array items will stay in the original order.

**Basic usage:**

```
use Dw\Utils\ArrayTogglePermutations;

$iterator = new ArrayTogglePermutations(
    [0,1,2]
);

// $iterator = new ArrayTogglePermutations(...);
foreach ($iterator as $permutation) {
    // Do something with the combination... For example:
    var_dump($permutation);
}
```

See [examples](./examples/).

Contributing
------------

[](#contributing)

See the [changelog](./CHANGELOG.md).

### File Signatures

[](#file-signatures)

Wherever possible, files should include a file signature comment.

```
/**
 * PHP Array Permutations Iterator.
 *
 * @since 1.0.0
 * @package Dw\Utils
 * @copyright 2021 Dom Webber
 * @link https://github.com/domwebber
 */
```

License
-------

[](#license)

[GNU GPL v3.0](https://choosealicense.com/licenses/gpl-3.0)

© 2021 Dom Webber

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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 ~0 days

Total

3

Last Release

1771d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15ebc40c86e602babd6ccdfc181b37ce5b65ee855ea6544cc42e1f7a719d70d8?d=identicon)[domwebber](/maintainers/domwebber)

---

Top Contributors

[![domwebber](https://avatars.githubusercontent.com/u/29407089?v=4)](https://github.com/domwebber "domwebber (17 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/domwebber-array-toggle-permutations/health.svg)

```
[![Health](https://phpackages.com/badges/domwebber-array-toggle-permutations/health.svg)](https://phpackages.com/packages/domwebber-array-toggle-permutations)
```

PHPackages © 2026

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