isemantics / php-math-parser

Simple mathematical expression parser and calculator.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Math

Simple mathematical expression parser and calculator.

Install

The recommended way to install Math is through composer.

{
    "require": {
        "aboyadzhiev/php-math-parser": "dev-master"
    }
}

Usage

Here is an simple example of evaluation of mathematical expression

<?php

$parser = new \Math\Parser();
$expression = '1 + 2 * 3 * ( 7 * 8 ) - ( 45 - 10 )';
$result = $parser->evaluate($expression);

echo $result; //302

TODO

  • Add unit tests.
  • Add additional strategy for translation from infix to reverse polish notation

License

MIT, see LICENSE.

About

Simple mathematical expression parser and calculator.

License:MIT License


Languages

Language:PHP 100.0%