2

I'm using NumberFormatter::formatCurrency to display formatted currency values, like this;

$value = 395;
$fmt = numfmt_create('en_GB', NumberFormatter::CURRENCY);
echo numfmt_format_currency($fmt, $value, 'gbp');

On my Windows dev box, and Centos UAT box, this outputs the desired £395.

But on the production Centos box, it outputs gbp395.

Any idea what is missing? I have checked intl extension is enabled.

Is there something wrong with my locale files perhaps? When I type

locale -a

in command line, I get a long list of locales, of which en_GB is one.

charliefortune
  • 3,072
  • 5
  • 28
  • 48

2 Answers2

0

Maybe en_GB is not a valid locale on your system. Try en_GB.UTF-8 or en_GB.ISO-8559-1 f.e.

huysentruitw
  • 27,376
  • 9
  • 90
  • 133
0

The NumberFormatter class is incorrect and the GBP needs to be in capital like so:'GBP'

Try this:

$value = 395;
$currencyFormat = new NumberFormatter('en_GB', NumberFormatter::CURRENCY);

echo $currencyFormat->formatCurrency($value, 'GBP');

This will render £395.00

harnamc
  • 541
  • 6
  • 20