number formatter php code example
Example 1: php number format
$num = 12345.6789;
echo number_format($num, 2, '.', '')
echo number_format($num, 3, ',', '.')
Example 2: number format php
<?php
echo number_format("1000000")."<br>";
echo number_format("1000000",2)."<br>";
echo number_format("1000000",2,",",".");
?>
Example 3: numberformatter php
$num = 1234567.891234567891;
$nf = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
echo $nf->format($num);
$nf = new NumberFormatter('uk_UA', NumberFormatter::CURRENCY);
echo $nf->formatCurrency($num, 'UAH');
$nf = new NumberFormatter('lt_LT', NumberFormatter::SPELLOUT);
echo $nf->format($num);
$nf = new NumberFormatter('en_US', NumberFormatter::DURATION);
echo $nf->format($num);
$nf = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$nf->setPattern('#,##0.### kg');
echo $nf->format($num);