3v4l.org

run code in 300+ PHP versions simultaneously
<?php $estimate = array( array( 'gear' => 'MMG', 'total' => 315, 'efforts' => 9, 'afh' => 18 ), array( 'gear' => 'MMG', 'total' => 400, 'efforts' => 2, 'afh' => 6, ), array( 'gear' => 'BOO', 'total' => 200, 'efforts' => 20, 'afh' => 16, ), array( 'gear' => 'BOB', 'total' => 250, 'efforts' => 20, 'afh' => 16, ) ); $result = array_reduce($estimate, function($carry, $item) { if (!isset($carry[$item["gear"]])) { $carry[$item["gear"]] = $item; return $carry; } $carry[$item["gear"]]["total"] += $item["total"]; $carry[$item["gear"]]["efforts"] += $item["efforts"]; $carry[$item["gear"]]["afh"] += $item["afh"]; return $carry; }); print_r($result);
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [MMG] => Array ( [gear] => MMG [total] => 715 [efforts] => 11 [afh] => 24 ) [BOO] => Array ( [gear] => BOO [total] => 200 [efforts] => 20 [afh] => 16 ) [BOB] => Array ( [gear] => BOB [total] => 250 [efforts] => 20 [afh] => 16 ) )

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:
42.78 ms | 406 KiB | 5 Q