3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( 0 => array ('User 1', 10, 10), 1 => array ('User 2', 10, 10), 2 => array ('User 1', 10, 10), 3 => array ('User 2', 10, 10), 4 => array ('User 1', 10, 10), 5 => array ('User 3', 10, 10), ); $result = array(); foreach($arr as $val){ $key = array_search($val[0], array_column($result, 0)); if($key !== false){ $result[$key][1] = $result[$key][1] + $val[1]; $result[$key][2] = $result[$key][2] + $val[2]; }else{ $result[] = $val; } } echo "<pre>";print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => Array ( [0] => User 1 [1] => 30 [2] => 30 ) [1] => Array ( [0] => User 2 [1] => 20 [2] => 20 ) [2] => Array ( [0] => User 3 [1] => 10 [2] => 10 ) )

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