среда, 12 мая 2021 г.

[Numberformatter] how to show plus sign after decimal number?

 If you need to show number for example "10.000+", where plus is in suffix, write:

$fmt = new NumberFormatter('es_ES', NumberFormatter::DECIMAL);
$fmt->setTextAttribute(NumberFormatter::POSITIVE_SUFFIX, '+');
$result = $fmt->format(10000);

Also if you use `NumberFormatter::POSITIVE_PREFIX` instead of `NumberFormatter::POSITIVE_SUFFIX`, you will get "+10.000".