我很困惑在PHP中使用round函数,我在我的系统中使用PHP制作了一些计算函数,但答案仍然没有四舍五入。
我希望所有总计将在 percent_complete 中进行舍入。
有人可以帮我修复此代码吗?这是原始代码..
<?php echo $row_sr1['percent_complete'] = ($row_sr1['partial_complete'] + $row_sr1['full_complete']) / $row_sr1['appt_today'] * 100;?>
,这是我尝试舍入但不成功的代码。
<?php echo round($row_sr1['percent_complete']),2 = ($row_sr1['partial_complete'] + $row_sr1['full_complete']) / $row_sr1['appt_today'] * 100;?>
答案 0 :(得分:3)
你的回合功能在错误的位置。
<?php
echo $row_sr1['percent_complete'] =
round(
($row_sr1['partial_complete'] + $row_sr1['full_complete']) /
$row_sr1['appt_today'] * 100,
2);
?>