Maybe this?
<?php
$num = '49.82';
$new_num = $num;
$hundredth = substr($num, -1, 1);
switch($hundredth)
{
case '0':
break;
case '1':
$new_num = ($new_num - 0.01);
break;
case '2':
$new_num = ($new_num - 0.02);
break;
case '3':
$new_num = ($new_num - 0.03);
break;
case '4':
$new_num = ($new_num - 0.04);
break;
case '5':
break;
case '6':
$new_num = ($new_num + 0.04);
break;
case '7':
$new_num = ($new_num + 0.03);
break;
case '8':
$new_num = ($new_num + 0.02);
break;
case '9':
$new_num = ($new_num + 0.01);
break;
}
echo $new_num;
?>
2
solved My rounding impossible (Javascript and PHP)