Page 1 of 1

Rounding to 2 Decimal Places

Posted: Wed Sep 07, 2011 5:35 am
by Nick11380
I'm really struggling to see how to do this. The following number is being posted:

As of <span id="theTime"></span> GMT, the gold price per ounce</a> in the UK is £'.$results['ounce_price'];

I want 'ounce_price' to be rounded to decimal places but can't figure how to do this.

Does 'round($results,2) ' mean anything in this situation? Where can I place the code. I'm a little confused, any help would be hugely appreciated!

Re: Rounding to 2 Decimal Places

Posted: Wed Sep 07, 2011 5:41 am
by theyapps
After $results['ounce_price'] has been set you can do:

round($results['ounce_price'], 2);

Re: Rounding to 2 Decimal Places

Posted: Wed Sep 07, 2011 5:47 am
by Nick11380
Perfect! Thank you very much, fixed the problem.

Re: Rounding to 2 Decimal Places

Posted: Wed Sep 07, 2011 6:11 am
by theyapps
Welcome :)