How to check the content of different words in several variables?

For example, we have a $tory variable, a $rety variable, and a $wer variable, we need to create a condition where the code will not be executed if $tory does not contain “hello” or “bye” and if $rety does not contain ” here” or “there” and if $wer does not contain “fas” or “ben”.

If at least one of the variables does not contain one of these words, then the code is not executed. My sketch:

if (
    $tory == "" ||
    $tory == "" ||
    $rety == "" ||
    $rety == "" ||
    $wer == "fas" ||
    $wer == "ben"
    )
{
    
}

But this code will work if at least one of the conditions is true.


Answer 1, authority 100%

Something like this:

if (
  ( $tory == "" || $tory == "" ) &&
  ( $rety == "" || $rety == "" ) &&
  ( $wer == "fas" || $wer == "ben" )
)

Answer 2, authority 100%

The code will not run if $tory does not contain “hello” or “bye” and if $rety does not contain “here” or “there” and if $wer does not contain “fas” or “ben”

The question contains the answer. =)

if( // 
    (strpos($tory, '') === false || strpos($tory, '') === false) && // $tory   ""  "" 
    (strpos($rety, '') === false || strpos($rety, '') === false) && // $rety   ""  "" 
    (strpos($wer, 'fas') === false || strpos($wer, 'ben') === false) // $wer   "fas"  "ben"
){} //    
else{
    //  
}

Although, of course, it’s better to invert all conditions and change “and” and “or” – this way you can do without else.


Answer 3, authority 100%

or so, for me personally – this code is better readable.

if (
    in_array($story, array("", "")) &&
    in_array($rety, array("", "")) &&
    in_array($rety, array("fas", "ben"))
   ) {
 ....
}