"something" is more than "all of these"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

"something" is more than "all of these"

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

if ( $str > max($stam, $con, $agi, $int) ) {
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

also..

Code: Select all

$total = array_sum($array);
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post 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
Post Reply