fork download
  1. <?php
  2.  
  3. $counter = 0;
  4. $runs = 10000;
  5. for($i=0;$i<$runs; $i++){
  6.  
  7. $num = rand(56,100);
  8. if($num == 100){
  9. $counter++;
  10. }
  11. }
  12.  
  13. echo "Using rand: In $runs runs, 100 was touched $counter times.\n";
  14. $counter = 0;
  15. for($i=0;$i<$runs; $i++){
  16.  
  17. $num = mt_rand(56,100);
  18. if($num == 100){
  19. $counter++;
  20. }
  21. }
  22.  
  23. echo "Using mt_rand: In $runs runs, 100 was touched $counter times.";
  24.  
  25.  
Success #stdin #stdout 0.03s 82560KB
stdin
Standard input is empty
stdout
Using rand: In 10000 runs, 100 was touched 244 times.
Using mt_rand: In 10000 runs, 100 was touched 210 times.