<?php $months = [ '2023-04', '2023-03', '2023-04', '2023-04', '2023-02', ]; $amounts = [ 833, 223, 829, 220, 498 ]; $sums = []; foreach($months as $i => $month) { if (!isset($sums[$month])) { $sums[$month] = 0; } $sums[$month] += $amounts[$i]; } var_dump($sums);
You have javascript disabled. You will not be able to edit any code.