3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = [ [ 'id' => 1331, 'label' => 'PMI', 'cost' => 98.25, 'cid' => 22, 'product_id' => 133, ], [ 'id' => 1341, 'label' => 'PMI', 'cost' => 98.25, 'cid' => 22, 'product_id' => 134, ], ]; $output = []; foreach ($data as $item) { if (!isset($output[$item['cid']])) { $output[$item['cid']] = [ 'label' => $item['label'], 'cost' => 0, 'cid' => $item['cid'], ]; } $output[$item['cid']]['cost'] += $item['cost']; } print_r($output);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [22] => Array ( [label] => PMI [cost] => 196.5 [cid] => 22 ) )

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:
53.51 ms | 1271 KiB | 4 Q