3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array('city' => 'NewYork', 'cash' => '1000'), array('city' => 'Philadelphia', 'cash' => '2300'), array('city' => 'NewYork', 'cash' => '2000'), ); $newarray = array(); foreach($arr as $ar) { foreach($ar as $k => $v) { if(array_key_exists($v, $newarray)) $newarray[$v]['cash'] = $newarray[$v]['cash'] + $ar['cash']; else if($k == 'city') $newarray[$v] = $ar; } } print_r($newarray);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [NewYork] => Array ( [city] => NewYork [cash] => 3000 ) [Philadelphia] => Array ( [city] => Philadelphia [cash] => 2300 ) )

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:
57.4 ms | 401 KiB | 8 Q