Simpler way to check if variable is not equal to multiple string values?
For your first code, you can use a short alteration of the answer given by @ShankarDamodaran using in_array(): if ( !in_array($some_variable, array(‘uk’,’in’), true ) ) { or even shorter with [] notation available since php 5.4 as pointed out by @Forty in the comments if ( !in_array($some_variable, [‘uk’,’in’], true ) ) { is the same … Read more