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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
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:
73.68 ms | 409 KiB | 5 Q