What's the correct way to round a PHP string to two decimal places?
(将PHP字符串四舍五入到小数点后两位的正确方法是什么?)
$number = "520"; // It's a string from a database
$formatted_number = round_to_2dp($number);
echo $formatted_number;
The output should be 520.00
;
(输出应为520.00
;)
How should the round_to_2dp()
function definition be?
(round_to_2dp()
函数定义应该如何?)
ask by Rich Bradshaw translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…