PHP数学方程函数

What i am really looking for is a maths equation function that takes in a string representing and equation and calculates the answer as a return type

For Example "(((4 * 5) + 6) * 2) / 8"

OutPut: 6.5

So in coding tearms something like

print calc("(((4 * 5) + 6) * 2) / 8");

Is there already a class or a function that some angel has built or do i gota do it my self

Thanks

As cloudhead said, just fixed up.

$nums = "(((4 * 5) + 6) * 2) / 8";
eval("\$nums = $nums;");
echo $nums;

you can use eval() for that, it'll evaluate the argument as php code:

$result = eval("(((4 * 5) + 6) * 2) / 8"); // 6.5
print $result;

If you end up rolling your own, read Smart design of a math parser or Equation expression parser with precedence. With explicit parentheses as in your example the parser would be much simpler.