I\'m trying to format revenue totals as grabbed from a db, and using php\'s NumberFormatter class, with the formatCurrency method.
However, I do not want to print ou
I came here because for some reason, $formatter->setSymbol(NumberFormatter::CURRENCY_SYMBOL, ''); was being ignored by $formatter->formatCurrency($array['total_revenue'], 'USD');
To resolve this issue, I found out a solution here. https://www.php.net/manual/en/numberformatter.setsymbol.php#124153
this could be obvious to some, but
setSymbol(NumberFormatter::CURRENCY_SYMBOL, '')doesn't work forformatCurrency- it will simply be ignored...use
NumberFormatter::CURRENCYand$fmt->format(123);to get a currency value with the symbol specified asCURRENCY_SYMBOL(orINTL_CURRENCY_SYMBOL)
i.e
$fmt = new NumberFormatter('de_DE', NumberFormatter::CURRENCY);
$fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, '');
$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
echo $fmt->format(56868993064.7985);
//Output: 56.868.993.064,80