我有一个类似的数组:
Array (
[0] => Array ( [IdProduct] => 1 [ProductName] => p1 [ProductCode] => pc1 [VendorId] => 1 [VendorName] => v1)
[1] => Array ( [IdProduct] => 2 [ProductName] => p2 [ProductCode] => pc2 [VendorId] => 1 [VendorName] => v1)
[2] => Array ( [IdProduct] => 3 [ProductName] => p3 [ProductCode] => pc3 [VendorId] => 1 [VendorName] => v1)
[3] => Array ( [IdProduct] => 4 [ProductName] => p4 [ProductCode] => pc4 [VendorId] => 2 [VendorName] => v2)
[4] => Array ( [IdProduct] => 5 [ProductName] => p5 [ProductCode] => pc5 [VendorId] => 2 [VendorName] => v2)
)
我正在尝试操纵数组,并希望输出如下所示:
Array(
['v1']=>array(
Array ( [IdProduct] => 1 [ProductName] => p1 [ProductCode] => pc1)
Array ( [IdProduct] => 2 [ProductName] => p2 [ProductCode] => pc2)
Array ( [IdProduct] => 3 [ProductName] => p3 [ProductCode] => pc3)
)
['v2']=>array(
Array ( [IdProduct] => 4 [ProductName] => p4 [ProductCode] => pc4)
Array ( [IdProduct] => 5 [ProductName] => p5 [ProductCode] => pc5)
)
)
我尝试了很多代码,但是没有运气,请帮助我!
答案 0 :(得分:3)
您可以使用v-layout
进行操作:
array_reduce