You can set manually the currency symbol, with
$nf->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, '<my symbol>');
& then use the format()
method for formatting. But i think, that's not what you want. For example:
$nf_en = new \NumberFormatter('en', \NumberFormatter::CURRENCY);
$nf_en->setTextAttribute(\NumberFormatter::CURRENCY_CODE, 'EUR');
$nf_en->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, 'EUR');
$nf_de = new \NumberFormatter('de', \NumberFormatter::CURRENCY);
$nf_de->setTextAttribute(\NumberFormatter::CURRENCY_CODE, 'EUR');
$nf_de->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, 'EUR');
echo $nf_en->format(1); // this will print 'EUR1.00'!
echo $nf_de->format(1); // this will print 'EUR 1,00'!
If you set the currency code to ''
, still there will be locales, where the formatted strings will start (or end) with white space(s). It would be easier to use the NumberFormatter
to format as a decimal number.