carriongrow/formula_parser
Composer 安装命令:
composer require carriongrow/formula_parser
包简介
Parses formulas, with the possibility of a deferred solution with substitution of user variables
README 文档
README
Parses formulas, with the possibility of a deferred solution with substitution of user variables
composer require carriongrow/formula_parser
Installation
$ composer require carriongrow/formula_parser
Description
Supported functions basic = '*', '/', '+', '-', '^' functional operations = 'cos', 'sin', 'exp', 'abs', 'log', 'sqrt', 'tan', 'pi'
cos sin tan - Do not require a transfer from degrees to the radian equivalent
Available symbols for dynamic variables: 0-9 a-z _ .or [a-z.0-9_] no dependence on the register!
Example
$parser = new FormulaParser(); $parser->setFormula('test1 * test2 * 2 (1 + 10) / 20'); // Parsing formulas once $counter = 1000; $result = []; while ($counter != 0) { // We use it as many times as we need $first = rand(1, getrandmax()) / getrandmax(); $second = rand(1, getrandmax()) / getrandmax(); $parser->setVariables(['test1' => $first, 'test2' => $second]); // Replacing user variables with values $result[] = $parser->calculate(); $counter--; }
more look in tests - https://github.com/AnatolySnegovskiy/FormulaParser/blob/master/test/FormulaParserTest.php
统计信息
- 总下载量: 104
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-21