title: Generate cryptographically secure random numbers in php
body: <p>PHP's <code>rand()</code> function doesn't give good random numbers. So I started to use <code>mt_rand()</code> which is said to give better results. But how good are these results? Are there any methods to improve them again?</p>
  
  <p>My idea:</p>
  
  <pre><code>function rand_best($min, $max) {
      $generated = array();
      for ($i = 0; $i &lt; 100; $i++) {
          $generated[] = mt_rand($min, $max);
      }
      shuffle($generated);
      $position = mt_rand(0, 99);
      return $generated[$position];
  }
  </code></pre>
  
  <p>This should give you "perfect" random numbers, shouldn't it?</p>