Say I have a string, $char. $char == \"*\".
$char. $char == \"*\".
I also have two variables, $a and $b, which equal \"4\" and \"5\" respectively.
How do I get the res
You can do with eval however I would not suggest using eval.
eval
If there is case operator can by anything you should check what operator is before using
switch($char) { case '*': $result= $a * $b; break; case '+': $result= $a + $b; break; }