I am working on a project where I need to make a function that will parse the 4 default math operations (addition, subtraction, multiplication, division). It would be nice i
You could use eval() (WARNING: be sure what enters is a math operation and not some other arbitrary input or php code).
$input = "3 + (4 - 2 * 8) / 2"; eval('$result = ' . $input . ';'); echo "The result is $result";