Aufgabe1($temp, $value); $function = str_replace($valueInBrache, $return, $function); } $function = str_replace(['(', ')'], "", $function); foreach (str_split($filterOperators) as $filterOperator) { $filter = $filterDigits . "\\" . $filterOperator . $filterDigits; $filter = "~" . $filter . "~"; while (true) { $subTermCount = preg_match($filter, $function, $subTerm); if ($subTermCount == 0) { break; } $subTermValuesCount = preg_match_all("~" . $filterDigits . "~", $subTerm[0], $subTermValues); if ($filterOperator == '/' && $subTermValues[1] == 0) { return "Asymptote"; } $ergebnis = $this->Calc($subTermValues[0][0], $subTermValues[0][1], $filterOperator); $function = str_replace($subTerm[0], $ergebnis >= 0 ? "+" . $ergebnis : $ergebnis, $function); $function = str_replace("-+", "-", $function); $function = str_replace("+-", "-", $function); $function = str_replace("--", "+", $function); $function = str_replace("++", "+", $function); } } return ltrim($function, "+"); } } $function = "((x * x) - 2 / (x + 8 * x) + 15)"; $value = -15; $calc = new Calculator(); echo $calc->Aufgabe1($function, $value); ?>