cowsdonthack Posted May 19, 2010 Share Posted May 19, 2010 Tried looking for a statement that provides an OR effectBasically I'm asking if the variable is equal to any of those three (or fifteen) thingsThen do whateverI tried || but it doesn't work (as in it just treats the {} as a new line and does it regardless of the if condition Link to comment Share on other sites More sharing options...
boen_robot Posted May 19, 2010 Share Posted May 19, 2010 The syntax is if (condition) {}, not (if condition) {}.The OR operator is "||".Show us your code if that's not it. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 19, 2010 Share Posted May 19, 2010 have you triedif($i == $mo || $i == $mu || $i == $meoo){do whatever}orif($i == "mo" || $i == "mu" || $i == "meoo"){do whatever} Link to comment Share on other sites More sharing options...
ShadowMage Posted May 19, 2010 Share Posted May 19, 2010 If you have a long list of things to check there's an easier way. Just create an array of the values you want to check and use the in_array function. $arrTestVals = array("moo", "mu", "meoo");if (in_array($variable, $arrTestVals)) { //Do something} Link to comment Share on other sites More sharing options...
cowsdonthack Posted May 19, 2010 Author Share Posted May 19, 2010 If you have a long list of things to check there's an easier way. Just create an array of the values you want to check and use the in_array function.$arrTestVals = array("moo", "mu", "meoo");if (in_array($variable, $arrTestVals)) { //Do something} Thank you jkloth, that TOTALLY rocked and worked. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.