Howto Format Numbers with technical Units (SI-Prefix) with PHP NumberFormatter

14 Views Asked by At

I would like to use the PHP class NumberFormatter (intl) to abbreviate large numbers (tech.) such as:

1 000 => 1K
1 500 => 1,5K
2 000 000 => 2M
2 000 000 000 => 2G
etc.

This does not really work.

With the locale "en_US", I get 1K, 1.5K, 2M and 2B With the German Locale "de_DE" I get 1 000, 1 500, 2 Mio and 2 Mrd

So I need the technical units of measurement (kilo, mega, giga, tera...) instead of the colloquial abbreviations. Apart from the number format, the multipliers should be independent of the locale.

Is this even possible with this formatter, or do I have to implement it myself? or is there perhaps another simple solution in PHP?

0

There are 0 best solutions below