Re: Round help needed

From: Date: Fri, 28 Sep 2012 03:13:57 +0000
Subject: Re: Round help needed
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-319290@lists.php.net to get a copy of this message
On Thu, Sep 27, 2012 at 11:05 PM, Chris Payne <oxygenet32@gmail.com> 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/

« previous php.general (#319290) next »