$nearest=10; $price=int(($price+$nearest/2)/$nearest)*$nearest;
This is parametric on the "granularity"
UPDATE: and it also works if $nearest is less than 1 (say you want to round to the nearest 0.5)
--
dakkar - Mobilis in mobile
In reply to Re: rounding to nearest
by dakkar
in thread rounding to nearest
by Cockneyphil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |