Page 1 of 1

"something" is more than "all of these"

Posted: Thu Jul 19, 2007 4:07 pm
by Mightywayne
Hi there.

I'm trying to figure out how to find if one variable, is more than a group of others, but NOT if they are added together. For example:

Code: Select all

if (10 > 1, 2, 3, 4)
Except in this case, it's

Code: Select all

if ($str > $stam, $con, $agi)
For those of you who know something about gaming, I'm testing to see if their strength ($str) is the highest of all attributes.

So even if $str was 10, but $stam was 8 and $con 9, $str would still be the highest and thus the code would happen.

Posted: Thu Jul 19, 2007 4:19 pm
by volka

Code: Select all

if ( $str > max($stam, $con, $agi, $int) ) {

Posted: Thu Jul 19, 2007 4:53 pm
by Benjamin
also..

Code: Select all

$total = array_sum($array);

Posted: Thu Jul 19, 2007 4:55 pm
by Mightywayne
Thanks. Btw, I love your $int xD That was cute. Like just assuming my monsters have int.

It actually would go like stamina, strength, constitution, agility, and then luck. From those stats, I get attack, defense, dodge, etc.

... anyways, thanks. xD