comparison in php using == and === operators -


In my application, values ​​like x, 1x, 2,1 etc. are created when running. I need to compare these:

As we know,

  x == 1 is false '1x' == 1 true '1' = = 1 is true  

For my application, first, other matters should be false and the third needs to be correct. If I use ===, then

  x === 1 is wrong '1x' === 1 is false 1 '=== 1 is false  < / Pre> 

So I can not compare these two

I think converting it into a string and then using strcmp would be the best option for me. Please share your thoughts Any answers are appreciated.

strcmp would be appropriate for this. But you should be aware of its return values

Returns & lt; 0 if str1 is less than str2; & Gt; 0 If str1 is larger than str2, and 0 if they are equal

Or you can also use Regex


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -