3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rows = [ 100 => [ ['product_id' => 101, 'name' => ''], ['product_id' => 102, 'name' => ''], ['product_id' => 103, 'name' => ''], ], 200 => [ ['product_id' => 201, 'name' => ''], ['product_id' => 202, 'name' => ''], ], 300 => [ ['product_id' => 301, 'name' => ''], ['product_id' => 302, 'name' => ''], ['product_id' => 303, 'name' => ''], ['product_id' => 304, 'name' => ''], ] ]; var_export( array_merge( #flatten the unpacked elements ...array_map( #unpack function(...$v) { #transpose discarding nulls return array_filter($v); #transpose discarding nulls }, #transpose discarding nulls ...$rows #transpose discarding nulls ) #unpack ) #flatten the unpacked elements );

preferences:
76.16 ms | 407 KiB | 5 Q