Your hordes should be u. The expression a != 1 || a != 2 a != 1 || a != 2 always true because, regardless of the value of a, one or the other of the expressions will be true, so the final result will be true.
To fix, change || at && .
I assume that you made this mistake because you started with this expression and wanted to invert it:
if ($planDetails['Company']['name'] == 'company1' || $planDetails['PlanDetail']['name'] == 'pd-name1' || $planDetails['PlanDetail']['name'] == 'pd-name2')
The easiest way to invert the following expressions:
if (!($planDetails['Company']['name'] == 'company1' || $planDetails['PlanDetail']['name'] == 'pd-name1' || $planDetails['PlanDetail']['name'] == 'pd-name2'))
Using this method, you don’t need to do any complicated logic in your head to see that it works - it’s just a denial of what you already know. Note that this is not the same as inverting == to != Individually. See De Morgan Laws for more details.
source share