3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( "0" => array( "id" => 1, "ip" => "10.40.47.5", "visited_ip" => "10.40.40.10", "quota" => 20, ), "1" => array( "id" => 2, "ip" => "10.40.47.20", "visited_ip" => "10.40.40.10", "quota" => 10, ), "2" => array( "id" => 1, "ip" => "10.40.47.5", "visited_ip" => "10.40.40.10", "quota" => 30, ) ); foreach($array as $item){ if(!isset($res[$item['id'] . ' ' . $item['ip']])){ $res[$item['id'] . ' ' . $item['ip']] = $item; }else{ $res[$item['id'] . ' ' . $item['ip']]['quota'] += $item['quota']; } } $res = array_values($res); var_dump($res);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> array(4) { ["id"]=> int(1) ["ip"]=> string(10) "10.40.47.5" ["visited_ip"]=> string(11) "10.40.40.10" ["quota"]=> int(50) } [1]=> array(4) { ["id"]=> int(2) ["ip"]=> string(11) "10.40.47.20" ["visited_ip"]=> string(11) "10.40.40.10" ["quota"]=> int(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:
129.89 ms | 406 KiB | 5 Q