private function _findPermutations($combination)
    {
        // If the combination only has 1 element, then the permutation is the same as the combination
        if (count($combination) <= 1) {
            return [$combination];
        }

        $permutationList = [];

        $startKey = $this->_processSubPermutations($combination, $permutationList);

        // Now that the first element has been rotated to the end, we calculate permutations until
        // we reach the first element which is now at the end of the combiatnion.
        $key = key($combination);
        while ($key != $startKey) {
            $this->_processSubPermutations($combination, $permutationList);
            $key = key($combination);
        }

        return $permutationList;
    }
private function _findPermutations($combination)
    {
        // If the combination only has 1 element, then the permutation is the same as the combination
        if (count($combination) <= 1) {
            return [$combination];
        }

        $permutationList = [];

        $startKey = $this->_processSubPermutations($combination, $permutationList);

        // Now that the first element has been rotated to the end, we calculate permutations until
        // we reach the first element which is now at the end of the combiatnion.
        $key = key($combination);
        while ($key != $startKey) {
            $this->_processSubPermutations($combination, $permutationList);
            $key = key($combination);
        }

        return $permutationList;
    }
private function _findPermutations ( $ combination ) { // If the combination only has 1 element, then the permutation is the same as the combination if ( count ( $ combination ) <= 1 ) { return [ $ combination ] ; } $ permutationList = [ ] ; $ startKey = $ this -> _processSubPermutations ( $ combination , $ permutationList ) ; // Now that the first element has been rotated to the end, we calculate permutations until // we reach the first element which is now at the end of the combiatnion. $ key = key ( $ combination ) ; while ( $ key != $ startKey ) { $ this -> _processSubPermutations ( $ combination , $ permutationList ) ; $ key = key ( $ combination ) ; } return $ permutationList ; }
Recursive function to find the permutations of the given combination.

@param array $combination Current combination set
@return array Permutations of the current combination
Recursive function to find the permutations of the given combination .