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 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
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 ) ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
175.74 ms | 408 KiB | 5 Q