Simple mathematical expression parser and calculator.
The recommended way to install Math is through composer.
{
"require": {
"aboyadzhiev/php-math-parser": "dev-master"
}
}
Here is simple example of evaluating math expression
<?php
$parser = new \Math\Parser();
$expression = '1 + 2 * 3 * ( 7 * 8 ) - ( 45 - 10 )';
$result = $parser->evaluate($expression);
echo $result; // 302
$expression = '-2+-2*13*(7*8)-(415-0.1)';
$result = $parser->evaluate($expression);
echo $result; // -1872.90
- Add additional translation strategy
MIT, see LICENSE.