我有一个这样的数组:
[
{
"Firepack_sn":"20012205",
"Installation_Date":"",
"Type":"EH","Standard":"VAS",
"Capacity_m3h":"81",
"Pressure_bar":"3,4",
"Rpm":"2930",
"Power_kw":"72"
},
{
"Firepack_sn":"20023901",
"Installation_Date":"",
"Type":"DH","Standard":"VAS",
"Capacity_m3h":"195",
"Pressure_bar":"4,2",
"Rpm":"2000",
"Power_kw":"72"
}
]
像这样的数组2:
[
{
"user_id":"40009",
"firepack_id":"20012205",
"activated":"1"
},
{
"user_id":"40009",
"firepack_id":"21020393",
"activated":"0"
}
]
现在我想过滤第一个数组,所以我只得到firepack_sn中存在于array2中的元素为firepack_id
所以我希望输出像这样:
[
{
"Firepack_sn":"20012205",
"Installation_Date":"",
"Type":"EH","Standard":"VAS",
"Capacity_m3h":"81",
"Pressure_bar":"3,4",
"Rpm":"2930",
"Power_kw":"72"
}
]
我怎样才能做到这一点?
答案 0 :(得分:1)
这是一种方法:
首先,你需要提取你需要查找的firepack_id,然后你需要遍历$ arr1并检查Firepack_sn是否与之前提取的firepack_id相同,如果是,则将其添加到一个数组。
URL
希望这有帮助。