3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( Array ( "contact_id" => 5000, 'invoice' => 476 ), Array ( 'contact_id' => 5000, 'invoice' => 396 ), Array ( 'contact_id' => 1490, 'invoice' => 1083 ), Array ( 'contact_id' => 1490, 'invoice' => 498 )); $res =array(); Foreach($arr as $subarr){ Foreach($subarr as $key => $val){ If($key == "contact_id") { If(!isset($res[$val])) $res[$val] = array(); $cid = $val; }Else{ $res[$cid][]= $val; } } } Var_dump($res);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [5000]=> array(2) { [0]=> int(476) [1]=> int(396) } [1490]=> array(2) { [0]=> int(1083) [1]=> int(498) } }

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:
26.67 ms | 405 KiB | 5 Q