Currently I am working with PHP 5.3.29 and the round() function in PHP_ROUND_HALF_DOWN mode to round a specific number.
Here is my code:
function getBetragrabatt($betrag, $rabatt, $ratezahl = false){
if(!empty($rabatt)){
$rabatt = str_replace(array(",", "."), array("", ""), $rabatt);
if($ratezahl >=1)
$abschlag = ($rabatt / $ratezahl);
else
$abschlag = $rabatt;
$abschlag = floor($abschlag / 100) . '.' . ($abschlag % 100);
$rabattbetrag = ($betrag - round($abschlag, 0, PHP_ROUND_HALF_DOWN));
}
return $rabattbetrag;
}
$rateRabatt = getBetragrabatt(119.95, 100, 18);
echo $rateRabatt;
If I use the code on sandbox (click here) everything works as expected and I get 119.95 as result.
If I use the same code within my IDE or upload it to my server, I get 119.40 as result.
What am I doing wrong? Hope you can help me..