FormulaParser.php
private function group(&$formula, $opt = 'init') {
        if ($opt == 'init') {
            // Numbers in E notation
            $formula = preg_replace_callback('/[\d\.]+( )?[eE]( )?[\+\-]?( )?[\d\.]+ /',
                    [$this, 'match'], $formula);
            // Variables
            if (count($this->variables) > 0) {
            	$valid_variables = implode("|", $this->valid_variables);
                $formula = preg_replace_callback('/[\+\-\*\/\^ ]('.$valid_variables.')[ \+\-\*\/\^]/',
                        [$this, 'match1'], $formula);
            }
        } else {
            // Functions
            $valid_functions = implode("|", $this->valid_functions);
            $formula = preg_replace_callback('/('.$valid_functions.')( )?[\+\-]?( )?[\d\.eEINF]+ /',
                    [$this, 'match2'], $formula);
        }
    }
private function group(&$formula, $opt = 'init') {
        if ($opt == 'init') {
            // Numbers in E notation
            $formula = preg_replace_callback('/[\d\.]+( )?[eE]( )?[\+\-]?( )?[\d\.]+ /',
                    [$this, 'match'], $formula);
            // Variables
            if (count($this->variables) > 0) {
            	$valid_variables = implode("|", $this->valid_variables);
                $formula = preg_replace_callback('/[\+\-\*\/\^ ]('.$valid_variables.')[ \+\-\*\/\^]/',
                        [$this, 'match1'], $formula);
            }
        } else {
            // Functions
            $valid_functions = implode("|", $this->valid_functions);
            $formula = preg_replace_callback('/('.$valid_functions.')( )?[\+\-]?( )?[\d\.eEINF]+ /',
                    [$this, 'match2'], $formula);
        }
    }
private function group ( & $ formula , $ opt = 'init' ) { if ( $ opt == 'init' ) { // Numbers in E notation $ formula = preg_replace_callback ( '/[\d\.]+( )?[eE]( )?[\+\-]?( )?[\d\.]+ /' , [ $ this , 'match' ] , $ formula ) ; // Variables if ( count ( $ this -> variables ) > 0 ) { $ valid_variables = implode ( "|" , $ this -> valid_variables ) ; $ formula = preg_replace_callback ( '/[\+\-\*\/\^ ](' . $ valid_variables . ')[ \+\-\*\/\^]/' , [ $ this , 'match1' ] , $ formula ) ; } } else { // Functions $ valid_functions = implode ( "|" , $ this -> valid_functions ) ; $ formula = preg_replace_callback ( '/(' . $ valid_functions . ')( )?[\+\-]?( )?[\d\.eEINF]+ /' , [ $ this , 'match2' ] , $ formula ) ; } }
Groups the parts of the formula that must be evaluated first into parentheses

@param string $formula
@param string $opt
Groups the parts of the formula that must be evaluated first into parentheses