Jump to content

(if variable == moo OR mu OR meoo){do whatever}


cowsdonthack

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...