SV: [PHP] Round to a given value?
| From: | Anders Norrbring | Date: | Thu, 25 Dec 2008 06:50:51 +0000 |
| Subject: | SV: [PHP] Round to a given value? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-285063@lists.php.net to get a copy of this message | ||
> On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote:
> > Rounding an integer to the closest divisor by ten is easy with
> round() and a
> > negative precision, but I turn out to be lost if I want to round to a
> given
> > number..
> >
> > Example, round to the closest 5000, or closest 400? Any great ideas?
> >
> > Thanks, and merry x-mas!
> > Anders.
> >
> >
> >
> http://www.alixaxel.com/wordpress/wp-content/2008/05/Round.php
>
> Someone was way ahead of you and found the answer and posted on the PHP
> manual pages back in May. The manual pages are always useful, even if
> only for the user-written functions!
>
>
> Ash
> www.ashleysheridan.co.uk
Thanks Ash.
I browse the pages frequently for ideas, and also did it yesterday..
However, I must have missed that post, maybe because it was so small in the
list.. ;-)
Thanks for the tip!
Anders.