note 88728 rejected from function.rand by danbrown

From: Date: Wed, 04 Feb 2009 22:30:20 +0000
Subject: note 88728 rejected from function.rand by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150235@lists.php.net to get a copy of this message
Note Submitter: brandonusa at gmail dot com ---- My questions is this: We have a code that uses the rand() function to execute a percentage of the time. here's the code: <? $random = rand(0, 100); echo $random; echo "\n"; ?> and I have a shell script to test the number of times the random number will be less then the frequency of 80 as follows. count=1 frequency=80 while [ $count -lt 1000 ] do randomnumber=php AdSource.php | tail -n 1 count=expr $count + 1 if test $randomnumber -lt $frequency then echo "random number is less then $frequency" fi done ~ ~ ~ ~ And the random number generated in php is less then the $frequency by a difference of 10 at most. This works for what I need to do, but why? How does the rand() function work?

« previous php.notes (#150235) next »