3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array(74.6779,25.918,44.9589); $total = array_sum($arr); $total_percentage = 0; foreach($arr as $total_item) { $percentage = ($total_item*100)/$total; $percentage = round($percentage,2); // without this works, but result large numbers.. e.g: "51.305693800548" echo $percentage; echo "\n"; $total_percentage+=$percentage; } echo round($total_percentage,2);
based on VIcM1
Output for 4.3.0 - 7.2.0
51.31 17.81 30.89 100.01