You may add new elements to the list by using the add
method:
$instance = new Combinatorics(["foo", "bar"]);
$instance->add("baz");
$instance->add("qux");
// ["foo", "bar", "baz", "qux"]
You may also want to reset the list of elements by calling the reset
method:
$instance = new Combinatorics(["foo", "bar"]);
$instance->reset();
// []
$elements = ["foo", "bar", "baz"];
$instance = new Combinatorics($elements);
foreach ($instance->permutations() as $value) {
...
}
// OR
foreach (Combinatorics::permutations($elements) as $value) {
...
}
// [
// ["foo", "bar", "baz"],
// ["bar", "foo", "baz"],
// ["bar", "baz", "foo"],
// ["foo", "baz", "bar"],
// ["baz", "foo", "bar"],
// ["baz", "bar", "foo"]
// ]
├── src
│ └── Combinatorics.php
├── tests
│ └── CombinatoricsTest.php
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .travis.yml
├── LICENSE.md
├── README.md
├── composer.json
├── composer.lock
└── phpunit.xml
This package is open-sourced software licensed under the MIT license.