<?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 " ;
}
PD9waHAKJGlucHV0PScyNDMgKyA2NzQzIC0gNzggKiAyID0nOwplY2hvICJBdCBmaXJzdCBJIHdhcyBsaWtlICRpbnB1dC4uLlxuIjsKcHJlZ19tYXRjaCgnL15bMS05XSovJywkaW5wdXQsJG1hdGNoKTsKJHN1bT0kbWF0Y2hbMF07CiRvcGVyYW5kMT0kbWF0Y2hbMF07CiRzdWJzdHJMZW5ndGg9c3Ryc3BuKCRpbnB1dCwiMTIzNDU2Nzg5MCIsKHN0cmxlbigkc3VtKSsxKSk7CmNhbGN1bGF0ZUl0KCRpbnB1dCwkb3BlcmFuZDEsKHN1YnN0cigkaW5wdXQsc3RybGVuKCRzdW0pKzEsJHN1YnN0ckxlbmd0aCkpLCRzdW0pOwoKZnVuY3Rpb24gY2FsY3VsYXRlSXQoJGlucHV0LCRvcGVyYW5kMSwkb3BlcmFuZDIsJHN1bSkKewoKJHN1YnN0ckxlbmd0aD1zdHJzcG4oJGlucHV0LCIxMjM0NTY3ODkwIiwoc3RybGVuKCRzdW0pKzEpKTsKJG9wZXJhbmQyPXN1YnN0cigkaW5wdXQsc3RybGVuKCRzdW0pKzEsJHN1YnN0ckxlbmd0aCk7CiRvcGVyPXN1YnN0cigkaW5wdXQsKHN0cmxlbigkc3VtKS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