inspirenmy/php-math-parser

Simple mathematical expression parser and calculator.

1.0.0 2019-02-06 04:55 UTC

This package is not auto-updated.

Last update: 2024-05-10 08:31:31 UTC


README

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.