-
- number_format(288);
- Output 288
-
- number_format(365,2);
- Output 365.00
-
- number_format(365000000,3,".") (retain the number 365000000 with 3 decimal places, small Use " for counting points". " means)
- Output: 365,000,000.000
-
- number_format(365000000,2,".","*") (retain the number 365000000 to 2 decimal places, the decimal point is represented by ".", and the thousand separator is represented by "*")
- Output: 365*000*000.00
Copy the code
Attached, an example of php intercepting the number of decimal places:
-
-
- // number_format method
- $number_format $number = 1234.5678;
- $nombre_format_francais = number_format($number, 2, ',', ' '); // 1 234 ,57
- $english_format_number = number_format($number, 2, '.', ''); // 1234.57
- // round method bbs.it-home.org
- round $number = 1234.5678; echo round($number ,2 ); //1234.57
- // sprintf method
- sprintf $formatted = sprintf ("%s has ¥%01.2f.", $name, $money); echo $formatted; //Zhang San has ¥123.10.
- ?>
-
Copy code
|