PHP四舍五入保留几位小数格式化数字
时间:2021-07-01 10:21:17
帮助过:19人阅读
-
- /** 1.number_format */
- $number = 1234.56789;
- $nombre_format_francais = number_format($number, 2, ',', ' ');
- $english_format_number = number_format($number, 2, '.', '');
-
-
- /** 2.round */
- $number = 1234.56789;
- echo round($number ,2);
-
-
- /** 3.sprintf */
- $formatted = sprintf ("¥%01.2f。", $money);
- echo $formatted;
-
- ?>
|
几位, 四舍五入, PHP