by prettyscripts on 2009-09-29 10:22:17
use php functions round() to round up or floor() to round down.
generic code, based on examples to round to nearest nickel (5c), dime (10c) and quarter (25c):
PHP:
$x = 100 / $cents_to_round_to; | |
$round_up = number_format(round($number * $x) / $x, 2); | |
$round_down = number_format(floor($number * $x)/ $x, 2); |