aboyadzhiev/php-math-parser

Simple mathematical expression parser and calculator.

Installs: 39 971

Dependents: 0

Suggesters: 0

Security: 0

Stars: 24

Watchers: 4

Forks: 18

Open Issues: 0

pkg:composer/aboyadzhiev/php-math-parser

2.0.0 2022-12-15 14:52 UTC

This package is auto-updated.

Last update: 2025-09-15 20:30:34 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 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

TODO

  • Add additional translation strategy

License

MIT, see LICENSE.