if (is_numeric($x) && $x == '1') { ...
It looks redundant to me. Why do we need to check if $x is_numeric AND the value is '1' ? We know that '1' is numeric, therefore, if it is equal to '1' , then it must be a number.
You can use comparison === :
If you're fine with interpreting it as a string:
if ($x === '1') { ...
or
If you must interpret the value as int
if ((int) $x === 1) { ...
or
If you do not need the actual type:
if ($x == '1') { ...
Charles Sprayberry
source share