3v4l.org

run code in 300+ PHP versions simultaneously
<?php $collections = [ 0 => [ 0 => [ "attr_id" => 23, "value" => "Single Side" ], 1 => [ "attr_id" => 23, "value" => "Double Side" ], ], 1 => [ 0 => [ "attr_id" => 31, "value" => "A4" ], 1 => [ "attr_id" => 31, "value" => "12x18" ], 2 => [ "attr_id" => 31, "value" => "B5" ], 3 => [ "attr_id" => 31, "value" => "A5" ] ] ]; $expected = []; foreach($collections as $k=>$v){ foreach($v as $k1=>$v1){ $expected[$v1['attr_id']][] = $v1['value']; } } print_r($expected) ?>
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.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
Array ( [23] => Array ( [0] => Single Side [1] => Double Side ) [31] => Array ( [0] => A4 [1] => 12x18 [2] => B5 [3] => A5 ) )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Array ( [23] => Array ( [0] => Single Side [1] => Double Side ) [31] => Array ( [0] => A4 [1] => 12x18 [2] => B5 [3] => A5 ) )

preferences:
161.61 ms | 402 KiB | 214 Q