【发布时间】:2017-08-27 19:39:18
【问题描述】:
请帮忙!我想验证具有重复子数组值的数组。我有一个多维数组。我想返回具有重复 product_id 值的子数组的键。示例:在我的数组中,我有重复 product_id = 124 的子数组。我想返回他们的密钥。
[purchase_order_products] => Array
(
[0] => Array
(
[product_id] => 124
[barcode] => 480001407081
[item_code] =>
[name] => Brew Kettle Can 330mL
[qty] =>
[unit] => 2
[pcs_have] => 1
[total_pcs] => 1
[cost] => 34.83
[total_item_price] => 34.83
[stocks] =>
[po_qty] =>
)
[1] => Array
(
[product_id] => 125
[barcode] => 480001416108
[item_code] =>
[name] => Colt 45 Can 330mL
[qty] =>
[unit] => 2
[pcs_have] => 1
[total_pcs] => 1
[cost] => 29.58
[total_item_price] => 29.58
[stocks] =>
[po_qty] =>
)
[2] => Array
(
[product_id] => 124
[barcode] => 480001407081
[item_code] =>
[name] => Brew Kettle Can 330mL
[qty] =>
[unit] => 2
[pcs_have] => 1
[total_pcs] => 1
[cost] => 34.83
[total_item_price] => 34.83
[stocks] =>
[po_qty] =>
)
)
我想要的输出是:
Array(0,2)
【问题讨论】:
-
整洁,现在尝试编写一些代码。
-
我已经更新了我的答案,现在它给出了要求多对重复项的确切输出。你会看看它,看看它是否能解决你的问题?
标签: php arrays laravel-5.2