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 關注
- 132 瀏覽
添加回答
舉報