number_format: the second parameter indicates the number of decimals after the decimal point
<?php
$i = 123456;
$f = 98765.567;
$si = number_format($i, 0, ',', '.');
$sf = number_format($f, 2);
echo "\$si = $si and \$sf = $sf\n";
?>
Related examples in the same category