liamloveslearning Posted May 19, 2010 Share Posted May 19, 2010 Hi everyone, im echoing a number value from my table as a number, I need to convert this to money format and ive found setlocale(LC_MONETARY, 'en_US'); echo money_format('%i', $number) . "\n"; how can i have this format my own variable? <?php echo $row_getsum['SUM_value']; ?> Would it be... setlocale(LC_MONETARY, 'en_US'); echo money_format('%i', $number . row_getsum['SUM_value'] . "\n"; Link to comment https://forums.phpfreaks.com/topic/202232-money-format/ Share on other sites More sharing options...
JAY6390 Posted May 19, 2010 Share Posted May 19, 2010 You shouldn't need this $number . in the final row of code. Also, surely trying the code would show if it works or not Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060448 Share on other sites More sharing options...
ignace Posted May 19, 2010 Share Posted May 19, 2010 echo money_format('%i', $number . row_getsum['SUM_value'] . "\n"; Where do you get this logic? Just use: echo money_format('%i', $row_getsum['SUM_value'] . "\n"; Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060449 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2010 Author Share Posted May 19, 2010 I did try I just tent to waffle for some reason, Ive just tried echo money_format('%i', $row_getsum['SUM_value'] . "\n"; only it errors and nothing is outputted, were entering values into the db such as 1234.56, could the decimal be a problem? Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060460 Share on other sites More sharing options...
JAY6390 Posted May 19, 2010 Share Posted May 19, 2010 remove the ; before the ) Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060461 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2010 Author Share Posted May 19, 2010 thanks Jay, Is there a way to change the money format GBP into the sterling symbol? <?php setlocale(LC_MONETARY, 'en_GB'); echo money_format('%i', $row_getsum['SUM_value']) . "\n"; ?> outputs as GBP1,234.13 Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060473 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2010 Author Share Posted May 19, 2010 trial and error, sorted! Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060476 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2010 Author Share Posted May 19, 2010 Thought id cracked it! Ive just tried <?php setlocale(LC_MONETARY, 'en_GB'); $locale_info = localeconv(); print_r($locale_info); ?> which when outputting shown my currency symbol as [currency_symbol] => � Does anybody know what causes this and how I can fix it? Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060485 Share on other sites More sharing options...
ignace Posted May 19, 2010 Share Posted May 19, 2010 Thought id cracked it! Ive just tried <?php setlocale(LC_MONETARY, 'en_GB'); $locale_info = localeconv(); print_r($locale_info); ?> which when outputting shown my currency symbol as [currency_symbol] => � Does anybody know what causes this and how I can fix it? Set the correct character set. Link to comment https://forums.phpfreaks.com/topic/202232-money-format/#findComment-1060513 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.