thefollower Posted December 7, 2007 Share Posted December 7, 2007 Either my maths sucks (which it does normally) lol or I've got the logic wrong here cos the result isn't doing what its suppose to! Its meant to add a % ($X) to a value which is($AttackHit). $AttackHit = 3; $X = array(); $X[] = '2'; $X[] = '1'; $X[] = '5'; $X[] = '5'; $X[] = '3'; $XKey = array_rand($X); $x = $X[$XKey]; $TotalAttackHit = $AttackHit*($x/100); } Echo $TotalAttackHit; The echo shows "0", so I am not sure what happened. But what is meant to happen is the % which is $X is meant to be "added" ontop "AttackHit" which becomes $ToalAttackHit. It turns out as 0 all the time though. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 7, 2007 Share Posted December 7, 2007 try this $AttackHit = 3; $X = array('2','1','5','5','3'); $XKey = array_rand($X); $x = $X[$XKey]; $TotalAttackHit = $AttackHit*($x/100); } Echo $TotalAttackHit; Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 7, 2007 Share Posted December 7, 2007 Your code never returns zero for me. I see you have a curly bracket in there; I'll wager that curly bracket goes with an if that never gets entered. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.