PHP - Money_format
how do I set money format to NO decimal places?
echo money_format('%(#10n', $reQ['capitalrequested']); Similar TutorialsIf I put this in a new HTML document: Code: [Select] <?php $number = 1234.56; // let's print the international format for the en_US locale setlocale(LC_MONETARY, 'en_US'); echo money_format('%i', $number) . "\n"; // USD 1,234.56 ?> as per the PHP manual, I get: Fatal error: Call to undefined function money_format() in C:\wamp\www\accounts\test.php on line 7 Line 7 is: echo money_format('%i', $number) . "\n"; I have tried setting different locales and same result. Any ideas on what I need to do to get it to work? Tried a number of different things but can't seem to get the decimal to show the 0 if the decimal is only a single digit. Currently using: Code: [Select] $conversion = number_format("$conversion",2); Thanks Hi, I have this money related function: function getMoneyUS( $pricesUS ) { setlocale( LC_MONETARY, 'en_US.UTF-8' ); return money_format( '%n', $pricesUS ); } Now, after the update to 7.4, it is showing in the logs as deprecated. The issue is money_format. I tried with NumberFormatter::formatCurrency but I either get an error or empty results. Examples I'm finding are not functions that can be applied multiple times, but for fixed values only. Examples like this: $fmt = numfmt_create( 'de_DE', NumberFormatter::CURRENCY ); echo numfmt_format_currency($fmt, 1234567.891234567890000, "EUR")."\n"; Or this: $fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY ); echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n"; I could not adapt them to my function. I understand that I do not need setlocale anymore, but this NumberFormatter only. But the exact working replacement is a challenge for me. I tried removing variable $fmt and replacing the fixed amount with my $priceUS, always some error or no result. |