PHP计算百分比,保留指定位小数,保留整数

$total = '100'; //总数
$single = '43'; //单个数
echo round($single /$total *100,2)."%<br />";//保留俩位小数
echo round($single /$total *100)."%";//保留整数

round() 方法返回浮点数x的四舍五入值。

猜你喜欢

转载自blog.csdn.net/weixin_46304253/article/details/108792679
今日推荐