note 14727 added to function.array-rand.php
| From: | alex at absolute dot lv | Date: | Sun, 12 Aug 2001 14:10:23 +0000 |
| Subject: | note 14727 added to function.array-rand.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16597@lists.php.net to get a copy of this message | ||
For php3 I think it'll be much easer to use:
srand ((double) microtime() * 10000000);
$ph2=0;
$from_num=0; //from what number need rand
$till_num=20; //till what number need rand
$how_much=5; //how much different numbers you need
while ($ph2<=$how_much){
$randval[$ph2] = rand($from_num,$till_num);
$check=0;
for ($x=1; $x<$ph2; $x++){
if ($randval[$ph2] == $randval[$x]) {$check=1;};
};
if ($check==0){$ph2++;};
};
for ($x=0; $x<=$how_much; $x++){
echo $randval[$x]; //on screen
};
http://www.php.net/manual/en/function.array-rand.php