anshul

06-16-2005, 07:33 AM

I've wrote this code

$max = 9;

for($i=0; count($random)<5; $i++) {

$random[$i]=rand(1, $max);

for($j=0; $j<count($random); $j++) {

if($random[$i]==$random[$j]) {

$random[$i]==NULL;

array_pop($random);

}

}

}

while(list($key, $value) = each($random))

echo $value . ", ";

Sometimes, I get repeated numbers; please help me, where I've mistaken.

ghost (http://www.mediasworks.com/webstory/cghost/blood.htm)

$max = 9;

for($i=0; count($random)<5; $i++) {

$random[$i]=rand(1, $max);

for($j=0; $j<count($random); $j++) {

if($random[$i]==$random[$j]) {

$random[$i]==NULL;

array_pop($random);

}

}

}

while(list($key, $value) = each($random))

echo $value . ", ";

Sometimes, I get repeated numbers; please help me, where I've mistaken.

ghost (http://www.mediasworks.com/webstory/cghost/blood.htm)