How to know the possible sets of n numbers?
<p>I have a set of numbers <code>S = [1,2,3,4,5,6];</code> And I want to make all possible pairs among them but one thing to know the pair could not be repeat.</p>

<p>i have used this :-</p>

<pre><code>$pairs = array('1','2','3','4','5','6');
$count = count($pairs);
$array = array();
for($i = 0;$i &lt;= $count; $i++){
    for($j = 1; $j &lt; $count; $j++){
        if($i &lt; $j){
            $array[$i][] = $pairs[$i].','.$pairs[$j];
        }
    }
}
</code></pre>

<p>I want some thing like this :- </p>

<pre><code>S = [1,2,3,4,5,6];

[1,2],[1,3],[1,4],[1,5],[1,6]
[2,3],[2,4],[2,5],[2,6]
[3,4],[3,5],[3,6]
[4,5],[4,6]
[5,6]
</code></pre>

<p>If anyone have any better suggestion please do reply as soon as possible. </p>
