Nick11380 Posted September 7, 2011 Share Posted September 7, 2011 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! Link to comment https://forums.phpfreaks.com/topic/246614-rounding-to-2-decimal-places/ Share on other sites More sharing options...
silkfire Posted September 7, 2011 Share Posted September 7, 2011 Nick, you're right! echo 'As of <span id="theTime"></span> GMT, the gold price per ounce</a> in the UK is £' . round($results['ounce_price'], 2) . '.'; Link to comment https://forums.phpfreaks.com/topic/246614-rounding-to-2-decimal-places/#findComment-1266367 Share on other sites More sharing options...
Nick11380 Posted September 7, 2011 Author Share Posted September 7, 2011 Simple! Thank you very much buddy, much appreciated! Link to comment https://forums.phpfreaks.com/topic/246614-rounding-to-2-decimal-places/#findComment-1266370 Share on other sites More sharing options...
voip03 Posted September 7, 2011 Share Posted September 7, 2011 sprintf http://php.net/manual/en/function.sprintf.php echo "£".sprintf('%.2f',$results['ounce_price']); Link to comment https://forums.phpfreaks.com/topic/246614-rounding-to-2-decimal-places/#findComment-1266372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.