如何比较元素数量不同的多维关联数组并过滤重复productID
问题描述
我有两个元素数量不固定的多维关联数组,无法确定数组A或B哪个元素更多。
原始数组
数组A
[0] => Array ( [catID] => 65 [discount] => 10 [productID] => Array ( [0] => 10887 [1] => 8508 [2] => 8350 ) [startDate] => 05/12/2022 12:00 am [endDate] => 10/12/2022 12:00 am ) [1] => Array ( [catID] => 66 [discount] => 10 [productID] => Array ( [0] => 13184 [1] => 10707 [2] => 8350 ) [startDate] => 10/12/2022 12:00 am [endDate] => 15/12/2022 12:00 am )
数组B
[0] => Array ( [catID] => 72 [discount] => 15 [productID] => Array ( [0] => 16239 [1] => 16236 [2] => 10887 [3] => 13184 [4] => 8524 [5] => 13314 ) [startDate] => 12/12/2022 12:00 am [endDate] => 15/12/2022 12:00 am )
期望结果
处理后的数组A(移除所有在数组B的productID中存在的productID)
[0] => Array ( [catID] => 65 [discount] => 10 [productID] => Array ( [1] => 8508 [2] => 8350 ) [startDate] => 05/12/2022 12:00 am [endDate] => 10/12/2022 12:00 am ) [1] => Array ( [catID] => 66 [discount] => 10 [productID] => Array ( [0] => 10707 ) [startDate] => 10/12/2022 12:00 am [endDate] => 15/12/2022 12:00 am )
数组B(无变化)
[0] => Array ( [catID] => 72 [discount] => 15 [productID] => Array ( [0] => 16239 [1] => 16236 [2] => 10887 [3] => 13184 [4] => 8524 [5] => 13314 ) [startDate] => 12/12/2022 12:00 am [endDate] => 15/12/2022 12:00 am )
内容的提问来源于stack exchange,提问作者enc
相关产品推荐
相关产品推荐

