I'm trying to produce an array with all variations of a product. There can be an unlimited amount of attributes and variations.
Provided array:
["Shirt"] # Product
["Color"] # Attribute
["Green"] # Variation
["Red"]
["Blue"]
["Size"]
["Small"]
["Medium"]
["Large"]
Expected result:
[0]
["type" => "Shirt"]
["color" => "Green"]
["Size" => "Small"]
[1]
["type" => "Shirt"]
["color" => "Green"]
["Size" => "Medium"]
...
[4]
["type" => "Shirt"]
["color" => "Red"]
["Size" => "Medium"]
[4]
["type" => "Shirt"]
["color" => "Red"]
["Size" => "Large"]
I've tried Laravel's and PHP's built-in functions, but haven't found success. I would really appreciate any insight.
See Question&Answers more detail:os