1. Go to this page and download the library: Download sobolevwladimir/vexcel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sobolevwladimir / vexcel example snippets
...
use SobolevWladimir\Vexcel\Parser\Parser;
$parser = new Parser();
$ast = $parser->parse('3+3');// Получили синтаксическое дерево
$answer = $ast->calculate(); // $answer = 6
$parser = new Parser();
$ast = $parser->parse('ВАША_ПЕРЕМЕННАЯ+3');// Получили синтаксическое дерево
foreach($repositorys as $repository) {
$answer = $ast->calculate($repository);
// ... you code
}
$parser = new Parser();
$ast = $parser->parse('ПЕРЕМЕН_ТРИ+3');// Получили синтаксическое дерево
$repository = new ValueRepositoryFake();// Наш репозиторий
$answer = $ast->calculate($repository); // $answer = 6
$parser = new Parser();
$ast = $parser->parse('ЕСЛИ(НЕ(3<2);"ДА";"НЕТ")');// Получили синтаксическое дерево
$answer = $ast->calculate(); // $answer = 'ДА'
$parser = new Parser(functionBuilder: new YouFunctionBuilder());
$ast = $parser->parse('МОЯФУНЦИЯ(3<2)');// Получили синтаксическое дерево
$answer = $ast->calculate();