3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [ ['ID' => 1, 'Count' => 2], ]; $b = [ ['ID' => 1, 'Count' => 4], ['ID' => 2, 'Count' => 3] ]; $result = []; foreach (array_merge($a, $b) as $row) { if (!isset($result[$row['ID']])) { $result[$row['ID']] = $row; } else { $result[$row['ID']]['Count'] += $row['Count']; } } var_export(array_values($result));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'ID' => 1, 'Count' => 6, ), 1 => array ( 'ID' => 2, 'Count' => 3, ), )

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:
72.29 ms | 405 KiB | 5 Q