Are there any php expressions or expressions for math javascript expressions (adds brackets)?

Google Calculator formats mathematical expressions in this way:

2+2/2 ---> 2 + (2 / 2) 2+2/2*PI ---> 2 + ((2 / 2) * PI) 

In other words, brackets are added. Are there any similar PHP or JavaScript solutions to do the same?

+4
source share
2 answers

Yes; The fastest and easiest way to not encode it yourself (for example, like Google) is using MathML .

Hope this helps!

+1
source

Of course you can just request a calendar via curl + ajax / postback? the result is a json array with left, right, error, etc.

Example request: http://www.google.com/ig/calculator?q=5*9%2B%28sqrt+10%29^3%3D

php / curl sample: http://www.dynamicguru.com/php/currency-conversion-using-php-and-google-calculator-api/#more-285

+1
source