jeudi 27 avril 2017

php if statement not working with or on stripos

Probably something simple, but I can't find the same thing on SO...

I have an php file that creates an html email, and I need to check for two (or more) pieces of text in a string.

When I just do a normal if, it executes:

if (stripos($Q5Answer, '2')  !== false) {
  message .= "<tr style='background: #eee;'><td> </td><td>". $Q5 ."</td>
</tr>"; 
}

But using an OR (using "OR" or "||"), it no longer displays

if (stripos($Q5Answer, '2') || stripos($Q5Answer, '1')  !== false) {
  message .= "<tr style='background: #eee;'><td> </td><td>". $Q5 ."</td>
</tr>"; 
}                   

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire