To do this the right way, reliably and safely, from scratch, you will need to perform:
Lexical analysis, this involves pattern matching the input with tokens:
(a x 5% - 2%)
would become something like the following chain of tokens:
openparen variable multiply integer percent minus integer percent closeparen
Syntax analysis, this involves taking those tokens and defining the relationships between them, something like this, matching up the patterns of tokens:
statement = operand operator statement
Then you will need to parse the resulting syntax tree so that you can run it and produce the answer.
It won't ever look as simple as $comm = $a * 5/100 - 2/100;
but it will result in the same conclusion.
Someone somewhere has already likely had a go at this problem, here's two I found after a brief Google search:
PHP Maths Expression Parser,
And another.
These SO questions are similar as well Smart design of a math parser?, Process mathematical equations in php