3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = Array ( '0' => Array ( 'location_id' => 1, 'property_id' => 10 ), '1' => Array ( 'location_id' => 2, 'property_id' => 20 ), '2' => Array ( 'location_id' => 3, 'property_id' => 10 ), '3' => Array ( 'location_id' => 4, 'property_id' => 10 ), '4' => Array ( 'location_id' => 5, 'property_id' => 10 ), '5' => Array ( 'location_id' => 6, 'property_id' => 20 ) ); $r = []; foreach($a as $v){ if(isset($r[$v['property_id']])){ array_push($r[$v['property_id']]['location_id'], $v['location_id']); }else{ $r[$v['property_id']] = [ 'property_id' => $v['property_id'], 'location_id' => [$v['location_id']] ]; } } print_r(array_values($r));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [property_id] => 10 [location_id] => Array ( [0] => 1 [1] => 3 [2] => 4 [3] => 5 ) ) [1] => Array ( [property_id] => 20 [location_id] => Array ( [0] => 2 [1] => 6 ) ) )

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