andersonrezende/formula-executor

字符串格式的公式转换器和执行器

v1.0.0 2023-07-03 21:26 UTC

This package is auto-updated.

Last update: 2024-09-04 00:09:01 UTC


README

简单的数学表达式计算器

安装

$ composer require nxp/math-executor

支持

  • 乘法
  • 除法
  • 加法
  • 减法
  • 乘方
  • 括号

基本用法

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();