I am looking for something that can interpret a string in php and do a simple mathematical calculation, and then return a boolean result as to whether the expression is true or false.
For instance:
- Sue in "3 * {mysalary} / 9 = 10000"
- PHP breaks this into two expressions - explode ('=', string);
- PHP takes my list of database fields and replaces any data-delimited "{}" fields (typecasted to int)
- PHP then evaluates the maths expression
- php then compares left side with right side
- Created boolean result.
It may seem complicated, but it should be very simple. Here are the limitations: 1 / the mathematical operators are fixed on: + - / * 2 / the comparison operators are tied to: => <> = <= 3 / no floating point comparisons are needed, everything can be done at the integer level. Thus, any divisions can be rounded if necessary, or simply simply round the end result.
There will be only two expressions with one comparison operator. If there is any error, we will simply return false.
Has anyone seen something that can do this? I know I can do something, but why reinvent the wheel?
If you havenโt seen anything, you need to indicate some โreceivedโ or a reservation that you can come up with when building this.
, . - PHP?
, eval , , , - . , , , .
.