Expression Evaluator
I looked around so much to find an expression evaluator, and none of my findings supported logical and comparison operators.
I created this package from a gist I found. I will be writing a service provider for Laravel 5.1 soon., (*1)
Example Usage
$exEngine = new ExpressionEvaluator\Engine;, (*2)
echo $exEngine->evalute('5 + 3 * 2');, (*3)
// outputs 11, (*4)
Example evaluations
5 + 3 * 2, (*5)
11, (*6)
(1 > 2 AND 3 < 2) OR 1+2 == 3, (*7)
0, (*8)
(3 > 2) AND (3 < 5), (*9)
1, (*10)
(1 > 2) OR (3 < 5), (*11)
1, (*12)
(1 > 2) OR (6 > 5), (*13)
1, (*14)
(1 > 2) OR (6 < 5), (*15)
0, (*16)
1 + 2 == 3, (*17)
1, (*18)
2 < 1 + 2, (*19)
2, (*20)
(2 < 1) + 2, (*21)
2, (*22)
((2 < 1) + 2) == 2, (*23)
1, (*24)
-8/-2, (*25)
4, (*26)
-8/2, (*27)
-4, (*28)
-8/-2 + 15 * 1, (*29)
19, (*30)
Inspired by & developed upon https://gist.github.com/ircmaxell/1232629, (*31)