0
I have a variable in PHP that mounts a logical string.
$str = "(('TR1'=='TR' OR 'TR2=='TR' OR 'TR'=='TR') AND ('10,0'=='10,1' OR '9,0'=='9,0'))";
I’d like to find a way that validation is possible, like:
if($str) "One of the parameters on each side is valid";
Has anyone been through it, or knows a way to solve it?
These parameters TR1, TR, TR2, etc are strings, in which case the first part will always be true since 'TR' == 'TR' is true. In the second part, after the AND, it will also always be true, because '9.0' == '9.0'. In this case it doesn’t make much sense why the
IF
. You can explain better?– David Alves
Of course, David, first of all, thank you so much for your interest in helping.. In the example yes the validation would always be true, but the real case is that the string will be the assembly of a reading in a database, where the expression itself is stored. So I need to validate and only proceed when the result of this expression is true.
– Jaques Oliveira