note 18692 added to function.mt-rand

From: Date: Thu, 31 Jan 2002 17:34:38 +0000
Subject: note 18692 added to function.mt-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-26098@lists.php.net to get a copy of this message
ok, an update to my last comment well, the rand function works, but looks like it has a limitation to it. look at this : function calcres($number) { global $Supplies; srand ((double) microtime() * 1000000); $retval = 0; $a = 0; if ($a!=$number) { do { $a++; # $tmp = rand(0,3+ # the rand is limited in the function, Especcially with the current formula that im using here. but the fix is quite simple. just change the rand to mt_rand this will increase your random findings and stablize your php program, ($supplies+$retval)); if ($tmp<20) $retval++; }while($a<$number); } return $retval; } This function will work best with the mt_rand runction and not only that, it is most defanitly more stable. meaning you will not hit the limitation that will cause the SQL event out of range error. -- http://www.php.net/manual/en/function.mt-rand.php http://master.php.net/manage/user-notes.php?action=edit+18692 http://master.php.net/manage/user-notes.php?action=delete+18692 http://master.php.net/manage/user-notes.php?action=reject+18692

« previous php.notes (#26098) next »