ali-eltaweel/cartesian-product

There is no license information available for the latest version (1.0.0) of this package.

PHP Iterables Cartesian Product

1.0.0 2025-07-21 20:32 UTC

This package is auto-updated.

Last update: 2025-07-21 20:34:16 UTC


README

PHP Iterables Cartesian Product

Installation

composer require ali-eltaweel/cartesian-product

Usage

use CartesianProduct\CartesianProduct;

$cp = new CartesianProduct();

$cp->add(['a', 'b', 'c']);
$cp->add(['1', '2', '3']);
$cp->add(['+', '-', '*']);

foreach ($cp as $combination) {

    // ...
}

With keys

use CartesianProduct\CartesianProduct;

$cp = new CartesianProduct();

$cp->add(['a', 'b', 'c'], 'letter');
$cp->add(['1', '2', '3'], 'number');
$cp->add(['+', '-', '*'], 'symbol');

foreach ($cp as $combination) {

    // ...
}