-
- print number_format(100000.56);
- ?>
Copy code
Example 2, number_format($n, $p, $t, $d) rounds $n to $ p decimal places, using $t as the thousands separator and $d as the decimal separator.
-
- echo "Total charge is ", number_format($total, 2, ".", ","), " Euros";
- ?>
Copy code
Example 3. The number_format function is used in English format and Italian format
-
-
$a = 1232322210.44; - echo number_format ($a, 2); // English format
- echo "n";
- echo number_format ($a, 2, ',', '.'); // Italian format
- echo "n";
- ?>
-
Copy code
Example 4, output formatted number form
-
- print "The population of the US is about:";
- print number_format(285266237);
- ?>
Copy code
|