hmm problem
$types = array("enc_monster", "enc_rare", "enc_ultrarare", "enc_trap", "enc_treasure");
$values = array(18, 22, 25, 15, 20);
$runningtotal = 0;
for($count=0; $count<5; $count++)
{
$runningtotal = $runningtotal + $values[$count];
if($enc_type <= $runningtotal){
echo "This random is a " . $types[$count];
break;
}
}
ok what this does is puts the types and the values (ie numbers of each type into arrays - indexed by number (ie 1 to 4)
then it loops through, each time adding the number of the next type to running total. So with the above values it would run through 18, 40 (ie 18+22), 65 (ie 18+22+25) etc etc
when the random number is less than or equal to this, it outputs the type and breaks the loop.
let me know if that helps - or doesn't!!!
ads