jasonc Posted July 16, 2011 Share Posted July 16, 2011 say my number is 1.2 i would like to have it show as 1.20 at two decimal places what is the correct method to do this. Quote Link to comment https://forums.phpfreaks.com/topic/242145-display-variable-at-two-decimal-places/ Share on other sites More sharing options...
wildteen88 Posted July 16, 2011 Share Posted July 16, 2011 Use number_format or sprintf Quote Link to comment https://forums.phpfreaks.com/topic/242145-display-variable-at-two-decimal-places/#findComment-1243551 Share on other sites More sharing options...
silkfire Posted July 16, 2011 Share Posted July 16, 2011 Easy, mate! $number = number_format(1.2, 2); Quote Link to comment https://forums.phpfreaks.com/topic/242145-display-variable-at-two-decimal-places/#findComment-1243578 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.