Re: Round help needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 27, 2012 at 11:05 PM, Chris Payne <oxygenet32@xxxxxxxxx> wrote:
> Hi everyone,
>
> I'm having one of those nights where nothing is working, please help
>
> What I have is this:
>
> $rounded_number = round($test, -3);
>
> Here's the problem i'm having, I need it to increment to the nearest 1000
> but it seems to only work if the number is over 500.  For example:
>
>
> 123666  WILL round to 124000 BUT if I put 123085 (As an example) it doesn't
> round it, it just stays at 123085 - I know it's probably something totally
> ridiculously simple but i'm having a mental block tonight.
>
> Any help would really be appreciated.

     Sounds like one of those "should be obvious, but isn't" issues.
This gives the desired result:

        <?php echo round(123085,-3); ?>

    So I wonder if it's your variable (perhaps even type-casting) or
some other portion of your code.  Can you elaborate and share some of
your bytes with the class, Mr. Payne?

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux