I want to make simple program that change operators "+", "-", "*", "/" for some numbers. So, I put operators in array, and try to iterate them through loop.
$num1 = 10;
$num2 = 20;
$operators = array("+", "-", "*", "/");
for ($x=0;$x<=count($operators)-1;$x++){
echo $num1 . $operators[$x] . $num2 . "</br>";
}
It displays:
10+5
10-5
10*5
10/5
That seems ok, at first glance, but I need numbers to be calculated, operations performed, simply, I need final result numbers, and this gives me 4 strings. I understand reason for this: my values in $operators array are strings, not real operators. My question is, how to put real operators in array, or maybe, I can keep them as strings in array, but somehow convert them in real operators at the output? Solutions for both strategies are welcome. Thanks in advance!