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){
    $result = $item[$this->orderField] . $operator . 1;
    echo $result;
}
                You could make functions that wrap the operators, or for simplicity just use the bc extension:
$operator = '+';
$operators = array(
  '+' => 'bcadd',
  '-' => 'bcsub',
  '*' => 'bcmul',
  '/' => 'bcdiv'
);
foreach($resultSet as $item){
    $result = call_user_func($operators[$operator], $item[$this->orderField], 1);
    echo $result;
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With