From ce4f938de0582536f2431371e9805bc86bd59e23 Mon Sep 17 00:00:00 2001 From: Lico San Date: Mon, 12 Aug 2019 16:46:04 +0200 Subject: [PATCH] Update README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 3654ee2..d30e982 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,26 @@ $f1 = new Formula1('-45+(fourty_one*2)-(6/(three+1))' , ['fourty_one'=>'82/2', ' echo($f1->compute()); // 35.5 ``` +**Display parsing error if any** + +```PHP +$f1 = new Formula1('-45+(fourty_one*2)-(6/(three+1)))' , ['fourty_one'=>'82/2', 'three'=>'12/four', 'four'=>4]); +if($f1->parse_error=='') echo($f1->compute()); +else echo($f1->parse_error."
\n"); // Too many closing parenthesis ! +``` + +**Use of a indexed array** +```PHP +$f1 = new Formula1('toto*primes[6]',['toto'=>10,'primes'=>[2,3,5,7,11,13,17,19,23,29,31]]); +echo($f1->compute()."
\n"); //170 +``` + +**Use of a key-value array** +```PHP +$f1 = new Formula1('toto*myar["zorglub_99"]',['toto'=>10,'myar'=>['aaa'=>2.5,'zorglub_99'=>5.5]]); +echo($f1->compute()."
\n"); //55 +``` + ## TODO * add math operations like sin, cos, sqrt etc...