public function getCombinations(array $sourceDataSet, $subsetSize = null)
    {
        // If the subset size is supplied, then just return the combinations that match such size
        if (isset($subsetSize)) {
            return $this->_getCombinationSubset($sourceDataSet, $subsetSize);
        }
        
        // Otherwise, we return all possible combinations
        $masterCombinationSet = [];
        
        // Calculate the combinations for all the possible lengths and add them to the master set
        $sourceDataSetLength = count($sourceDataSet);
        for ($i = 1; $i <= $sourceDataSetLength; $i++) {
            $combinationSubset    = $this->_getCombinationSubset($sourceDataSet, $i);
            $masterCombinationSet = array_merge($masterCombinationSet, $combinationSubset);
        }
        
        return $masterCombinationSet;
    }
public function getCombinations(array $sourceDataSet, $subsetSize = null)
    {
        // If the subset size is supplied, then just return the combinations that match such size
        if (isset($subsetSize)) {
            return $this->_getCombinationSubset($sourceDataSet, $subsetSize);
        }
        
        // Otherwise, we return all possible combinations
        $masterCombinationSet = [];
        
        // Calculate the combinations for all the possible lengths and add them to the master set
        $sourceDataSetLength = count($sourceDataSet);
        for ($i = 1; $i <= $sourceDataSetLength; $i++) {
            $combinationSubset    = $this->_getCombinationSubset($sourceDataSet, $i);
            $masterCombinationSet = array_merge($masterCombinationSet, $combinationSubset);
        }
        
        return $masterCombinationSet;
    }
public function getCombinations ( array $ sourceDataSet , $ subsetSize = null ) { // If the subset size is supplied, then just return the combinations that match such size if ( isset ( $ subsetSize ) ) { return $ this -> _getCombinationSubset ( $ sourceDataSet , $ subsetSize ) ; } // Otherwise, we return all possible combinations $ masterCombinationSet = [ ] ; // Calculate the combinations for all the possible lengths and add them to the master set $ sourceDataSetLength = count ( $ sourceDataSet ) ; for ( $ i = 1 ; $ i <= $ sourceDataSetLength ; $ i ++ ) { $ combinationSubset = $ this -> _getCombinationSubset ( $ sourceDataSet , $ i ) ; $ masterCombinationSet = array_merge ( $ masterCombinationSet , $ combinationSubset ) ; } return $ masterCombinationSet ; }
Creates all the possible combinations for the source data set.

@param array $sourceDataSet The source data from which to calculate combiantions.
@param int   $subsetSize    (Optional)<br/>If supplied, only combinations of the indicated
size will be returned.
<p>If the subset size is greater than the source data set size, only one combination will
be returned which includes all the elements in the source data set.</p>
<p>If the subset size is less or equal to 0, only one combination will be returned with
no elements.</p>
@return array A list of arrays containing all the combinations from the source data set.
Creates all the possible combinations for the source data set .