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"; Quote Link to comment 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 Quote Link to comment 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"; Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted May 19, 2010 Share Posted May 19, 2010 remove the ; before the ) Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 19, 2010 Author Share Posted May 19, 2010 trial and error, sorted! Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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.