相关疑难解决方法(0)

PHP如何向下舍入到小数点后两位?

我需要将PHP中的小数舍入到小数点后两位,以便:

49.955
Run Code Online (Sandbox Code Playgroud)

成为...

49.95
Run Code Online (Sandbox Code Playgroud)

我尝试过number_format,但这只是将值四舍五入到49.96.我不能使用substr因为数字可能更小(例如7.950).到目前为止,我一直无法找到答案.

任何帮助非常感谢.

php decimal rounding number-formatting

41
推荐指数
7
解决办法
5万
查看次数

标签 统计

decimal ×1

number-formatting ×1

php ×1

rounding ×1