<?php
$input = "22+2+45+56+55555555=";
for($i=0; $i <= strlen($input); $i++) {
$char = substr($input, $i, 1); if ($char == '*' || $char == '+' || $char == '-' || $char == "=" )
{
if($char == '*'){
$result = $pieces[0] * $pieces[1];
}
elseif($char == '+'){
$result = $pieces[0] + $pieces[1];
}
elseif($char == '-'){
$result = $pieces[0] - $pieces[1];
}
elseif($char == '='){
echo $result;
}
}
}
PD9waHAKCiAKIAokaW5wdXQgPSAiMjIrMis0NSs1Nis1NTU1NTU1NT0iOwogCiAKIAogCmZvcigkaT0wOyAkaSA8PSBzdHJsZW4oJGlucHV0KTsgJGkrKykKewogICAgJGNoYXIgPSBzdWJzdHIoJGlucHV0LCAkaSwgMSk7CiAgICBpZiAoJGNoYXIgPT0gJyonIHx8ICRjaGFyID09ICcrJyB8fCAkY2hhciA9PSAnLScgfHwgJGNoYXIgPT0gIj0iICkKICAgIHsKCQkkcGllY2VzID0gZXhwbG9kZSgkY2hhciwgJGlucHV0KTsKCQlpZigkY2hhciA9PSAnKicpewoJCQkkcmVzdWx0ID0gJHBpZWNlc1swXSAqICRwaWVjZXNbMV07CgkJfQoJCQllbHNlaWYoJGNoYXIgPT0gJysnKXsKCQkJJHJlc3VsdCA9ICRwaWVjZXNbMF0gKyAkcGllY2VzWzFdOwoJCX0KIAkJZWxzZWlmKCRjaGFyID09ICctJyl7CgkJCSRyZXN1bHQgPSAkcGllY2VzWzBdIC0gJHBpZWNlc1sxXTsKCQl9CgkJCQllbHNlaWYoJGNoYXIgPT0gJz0nKXsKIGVjaG8gJHJlc3VsdDsKCQl9CgkKIAogICAgfQp9CiA=