Monday, 7 July 2014

php round off value to multiples of 10

PHP Round Off values to multiples of 10


public function trimprice($currency, $x=5, $sf=2) {
$scale = pow(10,$sf);
$temp = round($currency * $scale, $sf); // get rid of small rounding errors
return number_format(round(ceil($temp / $x), $sf) * $x / $scale, $sf);
}

No comments:

Post a Comment