<?php
$input='243+6743-78*2=';
echo "At first I was like $input...\n";
$sum=$match[0];
$operand1=$match[0];
calculateIt
($input,$operand1,(substr($input,strlen($sum)+1,$substrLength)),$sum);
function calculateIt($input,$operand1,$operand2,$sum)
{
switch ($oper)
{
case "+": $sum+=$operand2; break;
case "-": $sum-=$operand2; break;
case "*": $sum*=$operand2; break;
case "/": $sum/=$operand2; break;
}
$input=str_replace($operand1.$oper.$operand2,$sum,$input); echo "...and then I $input \n";
$operand1=$sum;
calculateIt($input,$operand1,$operand2,$sum);
else echo "Finally I became this... $sum";
}
PD9waHAKJGlucHV0PScyNDMrNjc0My03OCoyPSc7CmVjaG8gIkF0IGZpcnN0IEkgd2FzIGxpa2UgJGlucHV0Li4uXG4iOwpwcmVnX21hdGNoKCcvXlsxLTldKi8nLCRpbnB1dCwkbWF0Y2gpOwokc3VtPSRtYXRjaFswXTsKJG9wZXJhbmQxPSRtYXRjaFswXTsKJHN1YnN0ckxlbmd0aD1zdHJzcG4oJGlucHV0LCIxMjM0NTY3ODkwIiwoc3RybGVuKCRzdW0pKzEpKTsKY2FsY3VsYXRlSXQoJGlucHV0LCRvcGVyYW5kMSwoc3Vic3RyKCRpbnB1dCxzdHJsZW4oJHN1bSkrMSwkc3Vic3RyTGVuZ3RoKSksJHN1bSk7CgpmdW5jdGlvbiBjYWxjdWxhdGVJdCgkaW5wdXQsJG9wZXJhbmQxLCRvcGVyYW5kMiwkc3VtKQp7Cgokc3Vic3RyTGVuZ3RoPXN0cnNwbigkaW5wdXQsIjEyMzQ1Njc4OTAiLChzdHJsZW4oJHN1bSkrMSkpOwokb3BlcmFuZDI9c3Vic3RyKCRpbnB1dCxzdHJsZW4oJHN1bSkrMSwkc3Vic3RyTGVuZ3RoKTsKJG9wZXI9c3Vic3RyKCRpbnB1dCwoc3RybGVuKCRzdW0pKSwxKTsKc3dpdGNoICgkb3BlcikKewogICAgY2FzZSAiKyI6ICRzdW0rPSRvcGVyYW5kMjsgYnJlYWs7CiAgICBjYX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