我有以下JSON。在PHP中,我需要遍历并将所有可能的产品/选项组合生成.csv文件。
我不知道如何编写此PHP代码。请帮忙。
我已经尝试过嵌套循环,但是还不太清楚如何做到这一点。任何指导将不胜感激。
输入为:
[
{
"name":"San Marino Flag Outdoor Nylon",
"model":"SANMARFL",
"options":{
"17":{
"name":"Select Flag Size",
"values":{
"60":{
"product_option_value_id":"1976",
"name":"5' x 8'"
},
"59":{
"product_option_value_id":"1975",
"name":"4' x 6'"
},
"77":{
"product_option_value_id":"1974",
"name":"3' x 5'"
},
"56":{
"product_option_value_id":"1973",
"name":"2' x 3'"
}
}
}
}
},
{
"name":"Certified Pre-Owned Blue Swooper Feather Flag",
"model":"SWFL-0021",
"options":{
"13":{
"name":"Add Mounting Hardware To Order?",
"values":{
"3251":{
"product_option_value_id":"24923",
"name":"X-Stand & Sand Bag"
},
"51":{
"product_option_value_id":"819",
"name":"Tire Base"
},
"50":{
"product_option_value_id":"820",
"name":"Ground Spike"
},
"49":{
"product_option_value_id":"821",
"name":"No"
}
}
},
"14":{
"name":"Add Swooper Aluminum Pole Kit To Order?",
"values":{
"53":{
"product_option_value_id":"822",
"name":"Deluxe 4-Piece Aluminum Flagpole Kit"
},
"52":{
"product_option_value_id":"823",
"name":"No"
}
}
}
}
}
]
输出必须为:
SANMARFL/1976, San Marino Flag Outdoor Nylon - Select Flag Size:5 x 8
SANMARFL/1975, San Marino Flag Outdoor Nylon - Select Flag Size:4 x 6
SANMARFL/1974, San Marino Flag Outdoor Nylon - Select Flag Size:3 x 5
SANMARFL/1973, San Marino Flag Outdoor Nylon - Select Flag Size:2 x 3
SWFL-0021/24923-822, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:X-Stand & Sand Bag|Add Swooper Aluminum Pole Kit To Order?:Deluxe 4-Piece Aluminum Flagpole Kit
SWFL-0021/819-822, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:Tire Base|Add Swooper Aluminum Pole Kit To Order?:Deluxe 4-Piece Aluminum Flagpole Kit
SWFL-0021/820-822, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:Ground Spike|Add Swooper Aluminum Pole Kit To Order?:Deluxe 4-Piece Aluminum Flagpole Kit
SWFL-0021/821-822, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:No|Add Swooper Aluminum Pole Kit To Order?:Deluxe 4-Piece Aluminum Flagpole Kit
SWFL-0021/24923-823, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:X-Stand & Sand Bag|Add Swooper Aluminum Pole Kit To Order?:No
SWFL-0021/819-823, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:Tire Base|Add Swooper Aluminum Pole Kit To Order?:No
SWFL-0021/820-823, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:Ground Spike|Add Swooper Aluminum Pole Kit To Order?:No
SWFL-0021/821-823, Certified Pre-Owned Blue Swooper Feather Flag - Add Mounting Hardware To Order?:No|Add Swooper Aluminum Pole Kit To Order?:No