php: round up and down to nearest cents

by prettyscripts on 2009-09-29 10:22:17 • Leave a comment »

php

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):$x = 100 / $cents_to_round_to;$round_up = number_format(round($number * $x) / $x, 2);$… more »

Tags: cents, php, rounding