From 98ca20f968510e8ab5f91b9d1752bf9430ab5052 Mon Sep 17 00:00:00 2001 From: Lico San Date: Mon, 17 Jun 2019 12:28:45 +0200 Subject: [PATCH] Update README.md --- README.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fcf76d3..4e84e35 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,27 @@ # Formula1 -**Simple Mathematical formulas evaluator for PHP** +##Simple Mathematical formulas evaluator for PHP If you need to evaluate a formula with basic operators and variables, and -- You dont want to use EVAL for obvious security reasons -- You don't want to rely on half the internet as dependancies, but prefer a single self-contained class -- You don't necessarily have the latest PHP version -- You want something readable that you could easily understand and customize. +- You dont want to use EVAL for obvious security reasons, +- You don't want to rely on half the internet as dependancies, but prefer a single self-contained class, +- You don't necessarily have the latest PHP version, +- You want something readable that you could easily understand and customize, Then you might like Formula1 ! ;-) + + +**Simple usage no variables** +$f1 = new Formula1('-45+(41*2)-(6/(3+1))'); +echo($f1->compute()); // 35.5 + +**Simple usage with variables** +$f1 = new Formula1('-45+(fourty_one*2)-(6/(three+1))' , ['fourty_one'=>41, 'three'=>3]); +echo($f1->compute()); + +**Funky usage with variables that include formulas themselves (and recusrively)** +$f1 = new Formula1('-45+(fourty_one*2)-(6/(three+1))' , ['fourty_one'=>'82/2', 'three'=>'12/four', 'four'=>4]); +echo($f1->compute()); + + +