angelsRock Posted October 11, 2007 Share Posted October 11, 2007 hi.. if the user enter 100000000 as the salary... how do i change that to become 100,000,000,000 ? Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/ Share on other sites More sharing options...
kenrbnsn Posted October 11, 2007 Share Posted October 11, 2007 Use the function number_format() Ken Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366686 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 <?php $number= number_format($number,',',3);?> Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366718 Share on other sites More sharing options...
cooldude832 Posted October 11, 2007 Share Posted October 11, 2007 sprintf() is a more generalized formated string function if you are interested in a more generalized solution. Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366726 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 number_format is more accurate Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366729 Share on other sites More sharing options...
cooldude832 Posted October 11, 2007 Share Posted October 11, 2007 I didn't say accurate, I said generalized Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366730 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 i know cool i use printf for my calculator Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366732 Share on other sites More sharing options...
cooldude832 Posted October 11, 2007 Share Posted October 11, 2007 actually sprintf would make more sense so you could get the $ in front also, but you can do that by hand i.e echo "$".$string; Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366733 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 thats troo. just depends on how you code it Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366734 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 i did something like printf('%_2f',$total); which output something like 100.29 instead of 100.292347949 Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-366737 Share on other sites More sharing options...
angelsRock Posted October 13, 2007 Author Share Posted October 13, 2007 great discussion above..haha anyway problem.. hahahaha echo $row[selling_price]; $row[selling_price]= number_format($row[selling_price],',',3); echo $row[selling_price]; the above echo show value but the later echo no... error Warning: Wrong parameter count for number_format() Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-368419 Share on other sites More sharing options...
darkfreaks Posted October 13, 2007 Share Posted October 13, 2007 get rid of number format and instead of echo use sprintf <?php sprintf('%000,3f');?> Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-368424 Share on other sites More sharing options...
sasa Posted October 13, 2007 Share Posted October 13, 2007 try <?php $a = 10000000000; echo number_format($a,','); ?> Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-368426 Share on other sites More sharing options...
darkfreaks Posted October 13, 2007 Share Posted October 13, 2007 sasa that wont work for her! she needs to use sprintf <?php sprintf('%000,3f',$row[selling_price]);?> Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-368427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.