I need a PHP calculator function to calculate values from a string variable.
It needs to take a string as input eg.
$input = "(1+4)*3";
Feed this value into the function and then output the answer (eg 15).
It needs to be able to deal with addition, subtraction, multiplication, division, decimals and brackets, as well as applying the correct mathematical order of operations.
If someone has a function that does this, great! Otherwise I can write the function myself if someone can point me in the right direction, and give me some ideas on the logic to take with this puzzle.
Any help appreciated :)