$num_one = rand(0,500);
$num_two = rand(0,500);
$num_three = rand(0,500);
$symbol = array('-','+');
for($i = 0; $i < 2; $i++){
$sym_save[] = $symbol[rand(0, 1)];
}
$example = "$num_one $sym_save[0] $num_two $sym_save[1] $num_three";
$num_one = rand(0,500);
$num_two = rand(0,500);
$num_three = rand(0,500);
$symbol = array('-','+');
for($i = 0; $i < 2; $i++){
$sym_save[] = $symbol[rand(0, 1)];
}
$example = "$num_one $sym_save[0] $num_two $sym_save[1] $num_three";
$result = eval("return $example;");
echo $example, ' = ', $result;