PHP NumberFormatter remove currency code prefix

87 views Asked by At

I want to use same currency code across all different locale. But i want to remove short currency code prefix from amount and only use currency symbol with amount.

for example: suppose default currency code is USD and locale is any one like en_US or en_CA.

the current output is in en_CA case: CA$100.00

But actually output is needed: $100.00

Solution needed in PHP language.

Tried code is

$locale = 'en_US';
$currencyCode = 'CAD'; // Canadian Dollar
$amount = 1234.56;

$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);

$formatted = $formatter->formatCurrency($amount, $currencyCode);
echo $formatted.PHP_EOL;  // Output: $1,234.56
0

There are 0 answers