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');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.