An open API service indexing awesome lists of open source software.

https://github.com/andersonrezende/formula-executor

Formula converter and executor in string format
https://github.com/andersonrezende/formula-executor

addition division executor exponentiation formula infix math multiplication notation polish postfix subtraction

Last synced: 2 months ago
JSON representation

Formula converter and executor in string format

Awesome Lists containing this project

README

        

# formula-executor ![Tests](https://github.com/AndersonRezende/formula-executor/actions/workflows/php.yml/badge.svg)
Simple math expression calculator

## Install:
```
$ composer require nxp/math-executor
```

## Support:
* Multiplication
* Division
* Addition
* Subtraction
* Exponentiation
* Parentheses

## Basic usage:
```php
use Andersonrezende\FormulaExecutor\FormulaExecutor;

$formula = '(a * (b + c) / d - e)';
$values = array('a' => 5, 'b' => 3, 'c' => 2, 'd' => 4, 'e' => 6);
$formulaExecutor = new FormulaExecutor($formula, $values);
$resultFormula = $formulaExecutor->execute();
```