我有两个数组$A
,$B
$B = Array
(
[0] => Array
(
[id_participant] => 94
[full_name] => soeng makara
)
[1] => Array
(
[id_participant] => 95
[full_name] => sok sao
)
)
$A = Array
(
[0] => Array
(
[id_participant] => 95
[full_name] => sok sao
)
)
任何人都可以帮助我在这种情况下如何检查数组$A
中的数组$B
。
答案 0 :(得分:3)
简单地:
if (in_array($A[0], $B))
{
// in array
}
答案 1 :(得分:2)
您想知道$ a中的项目是否在$ b?
function checkIfInArray($a, $b)
{
foreach($b as $i)
foreach($a as $x)
if($x['id_participant'] == $i['id_participant']) return true; //Match found
return false; //No Match was found
}