I have an array of <
and >
constraints on variable names that I get from the user:
$constraints = array('1<x','x<5','y>4');
Where $x
and $y
are defined in the relevant scope.
I want to verify that all the constraints hold (return true
or false
)
How can I do this without using eval
?
I concocted a partial answer here. It doesn't loop, but it does support the five different comparison operators.