Jump to content

Random Number Script


brown2005

Recommended Posts

<?php

 function rands($n,$s,$e) {
   $return = array();
   for ($i=0;$i<$n;$i++) {
     $num = rand($s,$e);
     do {
       $num = rand($s,$e);
     } while (in_array($num,$return));
      $return[] = $num;
   }
   return $return;
 }

 $rands = rands(3,1,100);
 foreach ($rands as $number) {
   echo $number . "\n";
 }

?>
       

Link to comment
https://forums.phpfreaks.com/topic/86156-random-number-script/#findComment-440019
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.