<?php //$total_sum = array_sum(array_column($packageInfo,'total_weight')); $total_sum = 26; $boxes = ceil($total_sum/20); // count of boxes for($i=0;$i<$boxes;$i++){ $res[$i]['box_item'] = ($total_sum - $i*20)>20 ? 20 : ($total_sum - $i*20); } print_r($res);
You have javascript disabled. You will not be able to edit any code.