I got problem why is it happen when I convert the number of ROUND(4.9813200498132,1) in PhpMyAdmin it result 5.0 then when i try to convert the value in php it result 5 only. how to make the result 5.0 to the php side.? is it need to convert the string number to int number? to understand well i will share to you guys the sample equation that i create.
Equation in php:
$first_wtd_item_first_option = str_replace( ',', '', $high_item_d_wtd_data->total_qty );
$first_wtd_item_second_option = str_replace( ',', '', $high_item_a_wtd_data->total_qty );
$first_wtd_item_third_option = str_replace( ',', '', $high_item_b_wtd_data->total_qty );
$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 = $first_wtd_item_computation2 * 100;
$first_wtd_item_final_result = (round($first_wtd_item_computation3,1).'%');
Output:
Thank you.
2
Answers
You should multiple with 10, not with 100, also you can use number_format()
Result:
5.0%
you can use number_format