我有一个数组,我似乎无法弄清楚如何查看每个数组项并检查 a 是否[Product Name]
与另一个数组项匹配[Product Name]
?
以下是样本数据。 例如,对于or之类的东西array[0]
,array[1]
两者都有相同[Product Name]
的 of但不同的值。我希望能够找到这样的匹配项并以某种方式将它们组合到一个数组中,但不会覆盖任何内容。test
[Variant Name]
[Variant Full Stock]
Array (
[0] => Array (
[Product Name] => test
[Variant Name] => Default
[Variant SKU] =>
[Variant In Stock] => 1
[Variant Full Stock] => 1
[id] => 0
)
[1] => Array (
[Product Name] => test
[Variant Name] => testingVar
[Variant SKU] =>
[Variant In Stock] => 1
[Variant Full Stock] => 2
[id] => 1
)
[2] => Array (
[Product Name] => another test
[Variant Name] => Default
[Variant SKU] =>
[Variant In Stock] => 1
[Variant Full Stock] => 1
[id] => 2
)
)
理想情况下,我想将上述数组转换为一个新数组,该数组将输出如下内容:
Array (
[0] => Array (
[0] => Array (
[Product Name] => test
[Variant Name] => Default
[Variant SKU] =>
[Variant In Stock] => 1
[Variant Full Stock] => 1
[id] => 0
)
[1] => Array (
[Product Name] => test
[Variant Name] => testingVar
[Variant SKU] =>
[Variant In Stock] => 1
[Variant Full Stock] => 2
[id] => 1
)
)
[1] => Array (
[Product Name] => another test
[Variant Name] => Default
[Variant SKU] =>
[Variant In Stock] => 1
[Variant Full Stock] => 1
[id] => 2
)
)
有什么解决办法吗?