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 ? Quote 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 Quote 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);?> Quote 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. Quote 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 Quote 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 Quote 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 Quote 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; Quote 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 Quote 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 Quote 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() Quote 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');?> Quote 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,','); ?> Quote 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]);?> Quote Link to comment https://forums.phpfreaks.com/topic/72709-change-the-decimal-point/#findComment-368427 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.