gple Posted August 31, 2007 Share Posted August 31, 2007 I want to take a variable and make sure that I output to the browser in dollar format ie if I set $price=100. I want to make sure that $price appears as 100.00. in turn make sure that when $price=100.97 is outputted as 100.97 Link to comment https://forums.phpfreaks.com/topic/67485-format-currency/ Share on other sites More sharing options...
Caesar Posted August 31, 2007 Share Posted August 31, 2007 <?php $price = number_format($price); ?> Link to comment https://forums.phpfreaks.com/topic/67485-format-currency/#findComment-338788 Share on other sites More sharing options...
gple Posted August 31, 2007 Author Share Posted August 31, 2007 I still dont see the .00. If it is .97 it gets rounded up to the next dollar Link to comment https://forums.phpfreaks.com/topic/67485-format-currency/#findComment-338797 Share on other sites More sharing options...
Barand Posted August 31, 2007 Share Posted August 31, 2007 echo '$'.number_format($price, 2); or printf ('$%0.2f', $price); Link to comment https://forums.phpfreaks.com/topic/67485-format-currency/#findComment-338832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.