3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar = [["count"=>6,"year"=>2019,"month"=>10,"name"=>"P","id"=>3,], ["count"=>2,"year"=>2019,"month"=>10,"name"=>"s.vimal","id"=>1,], ["count"=>4,"year"=>2019,"month"=>10,"name"=>"MR","id"=>2,], ["count"=>11,"year"=>2019,"month"=>11,"name"=>"s.vimal","id"=>1,], ["count"=>1,"year"=>2019,"month"=>12,"name"=>"MR","id"=>2,], ["count"=>4,"year"=>2019,"month"=>11,"name"=>"vimaltest","id"=>10,], ["count"=>1,"year"=>2019,"month"=>12,"name"=>"vimaltest","id"=>10,]]; $mon_ar = array_unique(array_column($ar,'month')); $year_ar = array_unique(array_column($ar,'year')); foreach($ar as $rec){ foreach($year_ar as $year){ foreach($mon_ar as $month){ if (!isset($result[$year.$month])) $result[$year.$month] = [ 'month' => $month, 'year' => $year]; if ($rec['year'] == $year && $rec['month'] <= $month) { if (!isset($result[$year.$month][$rec['name']])) $result[$year.$month][$rec['name']] = 0; $result[$year.$month][$rec['name']] += $rec['count']; } } } } sort($result); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [month] => 10 [year] => 2019 [P] => 6 [s.vimal] => 2 [MR] => 4 ) [1] => Array ( [month] => 11 [year] => 2019 [P] => 6 [s.vimal] => 13 [MR] => 4 [vimaltest] => 4 ) [2] => Array ( [month] => 12 [year] => 2019 [P] => 6 [s.vimal] => 13 [MR] => 5 [vimaltest] => 5 ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
162.21 ms | 407 KiB | 5 Q