PHPackages                             fabis94/php-twiddle - 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. fabis94/php-twiddle

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

fabis94/php-twiddle
===================

The Chase's Twiddle algorithm rewritten in PHP that returns all combinations of m out of n objects.

v2.0.0(4y ago)156.7kMITPHPPHP ^7.4|^8.0

Since Aug 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/fabis94/php-twiddle)[ Packagist](https://packagist.org/packages/fabis94/php-twiddle)[ RSS](/packages/fabis94-php-twiddle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

php-twiddle
===========

[](#php-twiddle)

Chase's Twiddle algorithm for returning all `m`-combinations of an array of size `n`. More info about the original algorithm can be found [here](http://dl.acm.org/citation.cfm?id=362502) and a C implementation can be found [here](http://www.netlib.org/toms-2014-06-10/382).

Unlike other recursive algorithms for building combinations this one allows you to build combinations iteratively and thus stop at any point when you've had enough without having to build all of the combinations first. This package provides both a PHP `\Generator` and a standard method for retrieving

Requirements
------------

[](#requirements)

PHP7.4 &amp; PHP8

How to use
----------

[](#how-to-use)

The following code will initialize a new Twiddle instance for building 2-combinations of a set of size 10.

```
$setSize = 10;
$combinationSize = 2;
$twiddle = new Twiddle($setSize, $combinationSize);
```

After initializing the instance you can run the algorithm on all arrays of size `n` (10 in the example).

```
// Get all possible combinations
$values = [1,2,3,4,5,6,7,8,9,0]
$allCombinations = $twiddle->getAllCombinations($values);

// Get first three combinations
$values = ['a','b','c','d','e','f','g','h','j','k']
$combinationGenerator = $twiddle->getCombinationGenerator($values);
$firstThree = [];
$i = 0;
foreach ($combinationGenerator as $combination) {
    if ($i >= 3) break;

    $firstThree[] = $combination;
    $i++;
}
```

Local development
-----------------

[](#local-development)

Run `docker-compose up -d` to run the docker environment. You can then SSH into one of the PHP containers (one has php7.4 and the other one has php8.0) to run `composer`, `tests` etc.: `docker-compose exec php7 bash` or `docker-compose exec php8 bash`

The codebase is going to be mounted onto `/app` inside the containers.

Run tests inside container with `composer test`.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

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

Total

2

Last Release

1695d ago

Major Versions

v1.0.0 → v2.0.02021-09-22

PHP version history (2 changes)v1.0.0PHP ^7.0

v2.0.0PHP ^7.4|^8.0

### Community

Maintainers

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

---

Top Contributors

[![fabis94](https://avatars.githubusercontent.com/u/938316?v=4)](https://github.com/fabis94 "fabis94 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fabis94-php-twiddle/health.svg)

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

###  Alternatives

[videlalvaro/azserverless

"PHP Custom Handler for Azure Functions"

182.3k](/packages/videlalvaro-azserverless)

PHPackages © 2026

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