本文整理汇总了PHP中Combination::getCombinations方法的典型用法代码示例。如果您正苦于以下问题:PHP Combination::getCombinations方法的具体用法?PHP Combination::getCombinations怎么用?PHP Combination::getCombinations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Combination
的用法示例。
在下文中一共展示了Combination::getCombinations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCombinationsInstance
public function testCombinationsInstance()
{
$mathCombination = new Combination();
// Size 0 combinations ---------------------------------------------------------------------
$combinationList0 = $mathCombination->getCombinations($this->_sourceDataSetKey, 0);
$expectedList0 = [];
$this->_assertCombination($combinationList0, $expectedList0, 0);
// Size 1 combinations ---------------------------------------------------------------------
$combinationList1 = $mathCombination->getCombinations($this->_sourceDataSetKey, 1);
$expectedList1 = [['a' => 5], ['b' => 6], ['c' => 8], ['d' => 10]];
$this->_assertCombination($combinationList1, $expectedList1, 4, 1);
// If this test pass, we don't need to check for other Index arrays as it proves that the
// combination is still treated as a map and thus if the key arrays tests pass, so would the
// indexed arrays
$combinationIdxList1 = $mathCombination->getCombinations($this->_sourceDataSetIdx, 1);
$expectedIdxList1 = [[0 => 5], [1 => 6], [2 => 8], [3 => 10]];
$this->_assertCombination($combinationIdxList1, $expectedIdxList1, 4, 1);
// Size 3 combinations ---------------------------------------------------------------------
$combinationList3 = $mathCombination->getCombinations($this->_sourceDataSetKey, 3);
$expectedList3 = [['a' => 5, 'b' => 6, 'c' => 8], ['a' => 5, 'b' => 6, 'd' => 10], ['a' => 5, 'c' => 8, 'd' => 10], ['b' => 6, 'c' => 8, 'd' => 10]];
$this->_assertCombination($expectedList3, $combinationList3, 4, 3);
// Size 4 combinations ---------------------------------------------------------------------
$combinationList4 = $mathCombination->getCombinations($this->_sourceDataSetKey, 4);
$expectedList4 = [['a' => 5, 'b' => 6, 'c' => 8, 'd' => 10]];
$this->_assertCombination($expectedList4, $combinationList4, 1, 4);
// All combinations ------------------------------------------------------------------------
$combinationList = $mathCombination->getCombinations($this->_sourceDataSetKey);
$expectedList = [['a' => 5], ['b' => 6], ['c' => 8], ['d' => 10], ['a' => 5, 'b' => 6], ['a' => 5, 'c' => 8], ['a' => 5, 'd' => 10], ['b' => 6, 'c' => 8], ['b' => 6, 'd' => 10], ['c' => 8, 'd' => 10], ['a' => 5, 'b' => 6, 'c' => 8], ['a' => 5, 'b' => 6, 'd' => 10], ['a' => 5, 'c' => 8, 'd' => 10], ['b' => 6, 'c' => 8, 'd' => 10], ['a' => 5, 'b' => 6, 'c' => 8, 'd' => 10]];
$this->_assertCombination($expectedList, $combinationList, 15);
}