How to produce a unique number from combination of 2 numbers (in any order) in PHP?
<p>How to produce a unique number from combination of 2 numbers in PHP ? For example, combination of these two numbers; 68 and 73, produce X ( X is a unique number). It does not matter how the order of the combination numbers, it should still produce same unique number. E.g: (68,73)=X or (73,68)=X
or combination of (1,2)=Y or (2,1)=Y , Y is a different number (because it's unique) from X.</p>

<p>Let me know if you need more information.</p>

<p>I think <a href="http://stackoverflow.com/questions/4226317/generate-a-unique-value-for-a-combination-of-two-numbers">this problem</a> is similar to my problem but it is written in C#.</p>

<p>I converted this code to PHP :</p>

<pre><code>function getUnique($x, $y){
  if($x&gt;$y){
    return $y | $x &lt;&lt; 32;
  }  else{
    return $x | $y &lt;&lt; 32;
  }
}

$list = array();
for($i=0 ; $i&lt;100 ;$i++){
  $x = rand(1,10); // I just put any random numbers from 1 to 10 so that I can read it easily.
  $y = rand(1,10);
  $unique = getUnique($x, $y);
  $list[$i] = '('.$x.','.$y.')='.$unique;
 }

//Find out the results
foreach($list as $ans){
   echo $ans.'&lt;br&gt;';
}
</code></pre>

<p>But, it does not produce unique numbers. Example from this results:</p>

<p>(2,9)=11</p>

<p>(10,1)=11</p>

<p>(2,9) should produce different number from (10,1).</p>
