相关疑难解决方法(0)

显示2位小数的数字

将PHP字符串舍入到2位小数的正确方法是什么?

$number = "520"; // It's a string from a database

$formatted_number = round_to_2dp($number);

echo $formatted_number;
Run Code Online (Sandbox Code Playgroud)

输出应该是520.00;

round_to_2dp()功能定义应该如何?

php formatting numbers rounding number-formatting

521
推荐指数
20
解决办法
103万
查看次数

标签 统计

formatting ×1

number-formatting ×1

numbers ×1

php ×1

rounding ×1