Thank you a lot for your excellent advices!
@Jacques1: Yes, I would like to output an error message!
@Ch0cu3r: I tried to use your version, but I get an error for the third line ($userdiv = preg_re...): <br /><b>Warning</b>: Wrong parameter count for preg_replace_callback() in <b>server/script.php</b> on line <b>59</b><br />
This is the code now:
while(strpos($userdiv, "/")!=false) {
preg_match_all("/([\d]+)\/([\d]+)/", $userdiv, $sta);
$userdiv = preg_replace_callback("/([\d]+)\/([\d]+)/", $userdiv);
function division($m) {
list(, $num1, $num2) = $m;
if($num1 == 0 || $num2 == 0) {
$sta = 'division by zero';
}
else
{
$userdiv=str_replace($sta[1][0].'/'.$sta[2][0], (int)$sta[1][0]/(int)$sta[2][0], $userdiv);
return $sta;
}
}
}
Have I done anything wrong with preg_replace_callback?
Thank you very much!