PHP保留2位小数
[ 2011-04-11 11:10:22 | 作者: admin ]
1.number_format
$number = 1234.5678;
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,57
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
2.round
$number = 1234.5678;
echo round($number ,2);
//1234.57
3.sprintf
$formatted = sprintf ("%s有¥%01.2f。",$name, $money);
echo $formatted;
//张三有¥123.10。
$number = 1234.5678;
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,57
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
2.round
$number = 1234.5678;
echo round($number ,2);
//1234.57
3.sprintf
$formatted = sprintf ("%s有¥%01.2f。",$name, $money);
echo $formatted;
//张三有¥123.10。
评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=1663
这篇日志没有评论。
此日志不可发表评论。