inspirenmy/php-math-parser

Simple mathematical expression parser and calculator.

Maintainers

👁 inspirenmy

Package info

github.com/inspirenmy/php-math-parser

pkg:composer/inspirenmy/php-math-parser

Statistics

Installs: 4 183

Dependents: 1

Suggesters: 0

Stars: 1

1.0.0 2019-02-06 04:55 UTC

Requires

  • php: >=5.3.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 8ac04a49b2efd04c7291e2a094da23ec627a51a6

  • Adrean Boyadzhiev <adrean.boyadzhiev.woop@gmail.com>

math parsershunting-yard algorithmmath calculator

This package is not auto-updated.

Last update: 2026-06-19 18:08:17 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.