title: Generating UNIQUE Random Numbers within a range
body: <p>I need to generate random UNIQUE numbers within a range, how can I do that? I can generate random number by</p>
  <pre><code>generator:
  $arr = [];
  $x = rand($min, $max);
  $len = count($arr);
  $flag = 0;
  for($i = 0; $i &lt; $len; $i++)
  {
   if ($flag === 1)
     goto generator;
   if ($x === $arr[$i])
     $flag = 1;
  }
  $arr[$index] = $x;
  $index++; 
  goto generator;
  </code></pre>
  <p>I know this code is bad, so I need a better optimized code of my version !
  help !</p>
  <p>example:
  if i need to generate 3 numbers within 1 to 15 they should be like 5, 9, 1 but not 3,1,2 [with in 1 - 3 (numbers i want to generate) ]</p>