【发布时间】:2016-04-02 02:21:13
【问题描述】:
你能帮我生成 Caresian 产品吗? 它类似于this stackoverflow。我想生成输入,所以我需要保留 ID。
例子:
我的输入数据:
[
1 => [
id => 1,
name => "Color",
options => [
5 => [
id => 5,
name => "Red"
],
6 => [
id => 6,
name => "Blue"
]
]
],
2 => [
id => 2,
name => "Size",
options => [
7 => [
id => 7,
name => "S"
],
8 => [
id => 8,
name => "M"
]
]
],
// etc
]
我期望的结果:
[
"5-7" => "Red / S",
"5-8" => "Red / M",
"6-7" => "Blue / S",
"6-8" => "Blue / M"
]
我需要任意数量的属性/选项的通用函数..
【问题讨论】:
-
到目前为止您尝试过什么?请先发布您尝试过的代码,然后我们可以看到您哪里出错了。
-
我尝试了上面写的其他stackoverflow的解决方案,但这不是我的目的。
标签: php associative-array cartesian-product