3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => [ "platform"=> "Google", "positive"=> "10", "negative"=> "5", "blocked"=> "1", ], 1 => [ "platform"=> "Yandex", "positive"=> "6", "negative"=> "2", "blocked"=> "1", ], 2 => [ "platform"=> "Google", "positive"=> "15", "negative"=> "35", "blocked"=> "23", ] ]; $result = array_values(array_reduce($array, function($carry, $item) { foreach($item as $k => $v) { if (isset($carry[$item['platform']][$k])) { if (is_numeric($v)) $carry[$item['platform']][$k] += $v; } else $carry[$item['platform']][$k] = $v; } return $carry; }, [])); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [platform] => Google [positive] => 25 [negative] => 40 [blocked] => 24 ) [1] => Array ( [platform] => Yandex [positive] => 6 [negative] => 2 [blocked] => 1 ) )

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:
54.68 ms | 402 KiB | 8 Q