I did some calculation and the result appears like this
how should I change it to 2 floating point= 17.30%
the variable for the result value come from
to make it easier i assigned it to another value
where and how should I change so that I get the value as mentioned above?
$value = 17.2962962963 ;
$value = round($value, 2);
That should do it. More information at http://www.php.net/round
You can also use printf() when all you need the rounded representation for is output.
$weight = $Totalrank[$temp_i] / $total_weight * 100;
This yields the benefit of retaining the precision from your calculation.