3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 'Colour' => [ 'Red' => 'Red', 'Blue' => 'Blue', ], 'Size' => [ 'Small' => 'Small', 'Medium' => 'Medium', 'Large' => 'Large', ], 'Brand' => [ 'Nike' => 'Nike', 'Adidas' => 'Adidas', ], ]; $combined = []; foreach ($data['Colour'] as $colour) { foreach ($data['Brand'] as $brand) { foreach ($data['Size'] as $size) { $combined[] = implode(' - ', [ $colour, $size, $brand ]); } } } var_dump($combined);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 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.18, 8.3.0 - 8.3.4, 8.3.6
array(12) { [0]=> string(18) "Red - Small - Nike" [1]=> string(19) "Red - Medium - Nike" [2]=> string(18) "Red - Large - Nike" [3]=> string(20) "Red - Small - Adidas" [4]=> string(21) "Red - Medium - Adidas" [5]=> string(20) "Red - Large - Adidas" [6]=> string(19) "Blue - Small - Nike" [7]=> string(20) "Blue - Medium - Nike" [8]=> string(19) "Blue - Large - Nike" [9]=> string(21) "Blue - Small - Adidas" [10]=> string(22) "Blue - Medium - Adidas" [11]=> string(21) "Blue - Large - Adidas" }
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(12) { [0]=> string(18) "Red - Small - Nike" [1]=> string(19) "Red - Medium - Nike" [2]=> string(18) "Red - Large - Nike" [3]=> string(20) "Red - Small - Adidas" [4]=> string(21) "Red - Medium - Adidas" [5]=> string(20) "Red - Large - Adidas" [6]=> string(19) "Blue - Small - Nike" [7]=> string(20) "Blue - Medium - Nike" [8]=> string(19) "Blue - Large - Nike" [9]=> string(21) "Blue - Small - Adidas" [10]=> string(22) "Blue - Medium - Adidas" [11]=> string(21) "Blue - Large - Adidas" }

preferences:
132.94 ms | 403 KiB | 172 Q