2 回答

TA贡献1874条经验 获得超12个赞
您应该使用 10 倍数,而不是 100,也可以使用number_format()
$first_wtd_item_first_option = str_replace( ',', '', $number);
$first_wtd_item_second_option = str_replace( ',', '', $number);
$first_wtd_item_third_option = str_replace( ',', '', $number);
$first_wtd_item_computation1 = $first_wtd_item_second_option + $first_wtd_item_third_option;
$first_wtd_item_computation2 = ($first_wtd_item_first_option / $first_wtd_item_computation1);
$first_wtd_item_computation3 = number_format((float) $first_wtd_item_computation2 * 10, 1, '.', '');
$first_wtd_item_final_result = $first_wtd_item_computation3.'%';
结果:
5.0%

TA贡献1966条经验 获得超4个赞
你可以使用number_format
$first_wtd_item_final_result = (number_format(round($first_wtd_item_computation3,1), 1).'%');
- 2 回答
- 0 关注
- 142 浏览
添加回答
举报