Possible Duplicate:
how to evaluate formula passed as string in php?
I have a string like “10*0.1+800” I would like to get the actual answer of the this string in numeric instead of the string value.
I have tried floatval php function but had no luck. Any idea?
You would have to “evaluate” the string using the eval function of PHP:
But i would really only do this, if you can trust the string. Because what you are doing here is indeed executing PHP code. It’s a possible security hole, if you can’t trust the string.
The other possible option would be to use a parser. I am sure, there are already any libraries for this task available.