Disclaimer: Auto generated file.
Please help us setting parameters to useful values and extending the examples.
- Combination::combinationsAll(array $set) : \Generator
/**
* All combinations of any size, ['a','b'] => [ ['a'], ['b'], ['a','b'] ]
* foreach(Combination:cominationsAll([1,2,3]) as $combinationIndex => $combination)
*
* @param array $set
* @return \Generator each combination as an array [ ['a'], ['b'], ['c'], ['a','b'], ['a','c'], ['b','c'], ['a','b','c'] ]
*/
- echo "<ul>";
foreach(Combination::combinationsAll([['a','b','c']); as $k => $v)
echo "<li>$k := ". print_r($v, true)."</li>";
echo "/<ul>";
- 0 := Array
(
[0] => a
)
- 1 := Array
(
[0] => b
)
- 2 := Array
(
[0] => c
)
- 3 := Array
(
[0] => a
[1] => b
)
- 4 := Array
(
[0] => a
[1] => c
)
- 5 := Array
(
[0] => b
[1] => c
)
- 6 := Array
(
[0] => a
[1] => b
[2] => c
)
- Combination::combinations(array $set = [], int $size = 0) : \Generator
/**
* All combinations, no duplicates, of size $size in $set as a Generator.
* foreach( combinations(['a','b','c'], 2) as $combinationIndex => $combination) => each $c is [a,b],[ a,c] and [b,c]
*
* @param array $set
* @param int $size
* @return \Generator
*/
- echo "<ul>";
foreach(Combination::combinations(); as $k => $v)
echo "<li>$k := ". print_r($v, true)."</li>";
echo "/<ul>";
- Combination::combinationsAllCount(int $setLength) : int
/**
* Number of all combinations for $setLength elements
*
* @param int $setLength
* @return int
*/
- Combination::combinationsAllCount(3); -> 7
- Combination::combinationsCount(int $setLength, int $itemsNumber) : int
/**
* Number of combinations of $setLength items grouped in $itemsNumber. considers a,b equal to b,a
*
* @param int $setLength
* @param int $itemsNumber
* @return int
*/
- Combination::combinationsCount(3, 3); -> 1
|