guys this is a simple question for most of you probably. but im confused on how can i perform operations with operator symbol saved in a variable. Example.
$first=5; $second=5; $operator="+"; $result=$first.$operator.$second; echo $result; but $result will just print 5+5. i want it to perform the operation.
my idea is to put it all operations in an if condition -> if($operator == '+'){add the first and second operand}. any other ideas guys?
eval(). That's usually an indicator that you should be doing something different. I suggest reviewing your strategy.