php - strpos with two words to find -
i found example on stackoverflow:
if (strpos($a,'are') !== false) { echo 'true'; } but how make search 2 words. need this: if $a contains words "are" or "be" or both echo "contains";
i tried xor , ||
just check both words separately , use boolean or-operator check if either 1 or both contained in $a:
if (strpos($a,'are') !== false || strpos($a,'be') !== false) { echo "contains"; } note due or-operator, second check (for 'be') not performed if first 1 showed $a contains 'are'.
Comments
Post a Comment