3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrays = [ [ "id" => 1, "order_id" => 1, "image_url" => "/resources/filename1" ], [ "id" => 2, "order_id" => 1, "image_url" => "/resources/filename2" ], [ "id" => 3, "order_id" => 1, "image_url" => "/resources/filename3" ], [ "id" => 4, "order_id" => 2, "image_url" => "/resources/filename4" ], ]; foreach($arrays as $array) { if(!isset($result[$array['order_id']]['id'])) { $result[$array['order_id']]['id']=$array['id']; } $result[$array['order_id']]['order_id']=$array['order_id']; $result[$array['order_id']]['image_url'][]=$array['image_url']; } print_r($result);
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [1] => Array ( [id] => 1 [order_id] => 1 [image_url] => Array ( [0] => /resources/filename1 [1] => /resources/filename2 [2] => /resources/filename3 ) ) [2] => Array ( [id] => 4 [order_id] => 2 [image_url] => Array ( [0] => /resources/filename4 ) ) )

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:
25.95 ms | 407 KiB | 5 Q