slim_jimmy7 Posted March 31, 2010 Share Posted March 31, 2010 I can't find if this is legit php code anywhere, so I though I would ask here! Basically I want to see if a variable is greater than multiple variables. Sorry if this is simple, I am new at php! Would this be the way to see if a variable is greater than all the variables? $a = 1; $b = 2; $c = 3; $d = 4; $value = 10; if ($c > $a AND $b AND $d) { $variable = $value; } else { $variable = 0; } Link to comment https://forums.phpfreaks.com/topic/197144-php-if-with-multiple-variables/ Share on other sites More sharing options...
the182guy Posted March 31, 2010 Share Posted March 31, 2010 You can do that like this: if ($c > $a && $c > $b && $c > $d) { // $c is greater than a, b and d } else { } Link to comment https://forums.phpfreaks.com/topic/197144-php-if-with-multiple-variables/#findComment-1034838 Share on other sites More sharing options...
slim_jimmy7 Posted March 31, 2010 Author Share Posted March 31, 2010 Thank you for clearing that up, I think I had multiple syntax crap going on. Link to comment https://forums.phpfreaks.com/topic/197144-php-if-with-multiple-variables/#findComment-1034853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.