使用round()函数

$number = 123.45678;

$rounded_number = round($number, 2);

echo $rounded_number; // 输出123.46

使用sprintf()函数

$number = 123.45678;

$formatted_number = sprintf(“%.2f”, $number);

echo $formatted_number; // 输出123.46

使用number_format()函数

$number = 123.45678;

$formatted_number = number_format($number, 2);

echo $formatted_number; // 输出123.46

作者 admin

百度广告效果展示