numberformatter php

Solutions on MaxInterview for numberformatter php by the best coders in the world

showing results for - "numberformatter php"
Isabel
12 Jan 2020
1/* PHP class to format numbers, currencies, percentages et cetera according
2to the specified or default locale class. One must install and enable PHP
3intl extension to utilize the NumberFormatter class. */
4
5$num = 1234567.891234567891;
6
7$nf = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
8echo $nf->format($num);
9
10$nf = new NumberFormatter('uk_UA', NumberFormatter::CURRENCY);
11echo $nf->formatCurrency($num, 'UAH');
12
13$nf = new NumberFormatter('lt_LT', NumberFormatter::SPELLOUT);
14echo $nf->format($num);
15
16$nf = new NumberFormatter('en_US', NumberFormatter::DURATION);
17echo $nf->format($num);
18
19$nf = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
20$nf->setPattern('#,##0.### kg');
21echo $nf->format($num);