我有 2 个集合,第一个集合来自带有 where 条件的查询,而第二个集合来自所有项目。我打算合并这两个集合,但是在第一个数组和第二个数组之间有相同的项目。合并后如何使项目独一无二?
这是第一个数组,
[
{
"id": 71,
"id_brand": 1,
"id_brand_outlet": 14,
"id_user": 5,
"id_brand_outlet_tujuan": 15,
"alasan": "Try",
"no_surat": "JJ-00001-1",
"created_at": "2020-03-10 08:57:00",
"updated_at": "2020-03-10 08:57:00",
"type": "Delivery Out",
"category": "ITEM MASUK",
"brand_items": [
{
"id": 1,
"id_brand": 1,
"id_brand_delivery": 71,
"id_brand_item": 1,
"id_unit": 2,
"qty_before": 10,
"qty_change": 10,
"qty_after": 0,
"created_at": "2020-03-10 08:57:00",
"updated_at": "2020-03-10 08:57:00",
"name": "ALPUKAT",
"id_unit_opname": 2,
"unit_opname": {
"id": 2,
"name": "Pcs",
"created_at": "2019-09-19 00:00:00",
"updated_at": "2019-09-19 00:00:00"
}
},
{
"id": 8,
"id_brand": 1,
"id_brand_delivery": 71,
"id_brand_item": 8,
"id_unit": 2,
"qty_before": 10,
"qty_change": 10,
"qty_after": 0,
"created_at": "2020-03-10 08:57:00",
"updated_at": "2020-03-10 08:57:00",
"name": "GULA AREN",
"id_unit_opname": 2,
"unit_opname": {
"id": 2,
"name": "Pcs",
"created_at": "2019-09-19 00:00:00",
"updated_at": "2019-09-19 00:00:00"
}
}
]
}
]
在第一个数组中有brand_items名称“ALPUKAT”和“GULA AREN”,第二个数组中也有相同的项目。如何使第一个数组中的项目不再出现在第二个数组中?我尝试过组合两个数组,但这些项目仍然不是唯一的。
红糖糍粑
江户川乱折腾
眼眸繁星
绝地无双
随时随地看视频慕课网APP