[英]php unique values from multi-dimensional array
I am strugglin' with following array to retreive the unique values. 我正在努力与以下数组检索独特的价值。 This array comes from a nested product assembly structure. 该数组来自嵌套的产品组装结构。 Tried several techniques but no result yet. 尝试了几种技术,但没有结果。 Maybe someone can help me with this? 也许有人可以帮我这个忙吗? Thanks in advance! 提前致谢!
Array
(
[0] => Array
(
[product_ID] => 1
[amount] => 2.00
)
[1] => Array
(
[product_ID] => 1
[amount] => 2.00
)
[2] => Array
(
[product_ID] => 1
[amount] => 2.00
)
[3] => Array
(
[product_ID] => 5
[amount] => 6.00
)
)
Goal is to retreive an array like:
目标是检索数组,如:
Array ( [0] => Array ( [product_ID] => 1 [amount] => 2.00 )
\n\n
\n\n[1] => Array ( [product_ID] => 5 [amount] => 6.00 )
) )
因为索引是唯一的,所以最简单的方法也可能是提取通过product_ID
建立索引的数组:
$result = array_column($array, null, 'product_ID');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.