Given this example, how would I return the result of the equation rather than the equation itself as a string?
$operator = \'+\'; foreach($resultSet as $item
You can use eval(), but it's generally a bad idea, since it's a major potential security hole (be careful you're not allowing visitors to run arbitrary code!).
It can also result in hard to maintain code.