Format an integer and a floating-point value with the number_format() function. : number_format « Data Type « PHP






Format an integer and a floating-point value with the number_format() function.

 
<?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

1.Formatting Numbers As Text
2.number_format for English format and Italian format
3.number_format($n, $p, $t, $d) rounds $n to $p decimal places, using $t as the thousands separator and $d as the decimal separator.
4.number_format($n,$p) rounds $n to $p decimal places, adding commas between thousands
5.number_format() enables us to determine the precision we require using a second argument: an integer.
6.number_format: the second parameter indicates the number of decimals after the decimal point
7.Printing a formatted number