我有两个数组 $schoolteachers 和 $schoolgroups ......
$schoolgroups=Array ([0] = Array ([groupid] = 1 [groupname] =Red [members] = Array ([0] = Array ([id] = 13 [name] = Sooraj)
[1] = Array ( [id] = 12 [name] = sanjay ) ) ) [1] => Array ( [groupid] = 2 [groupname] = Blue [members] = Array ( [0] = Array ( [id] = 9 [name] = Anith ) [1] = Array ( [id] = 4 [name] = John ) );
$schoolteachers=数组(
[0] => Array ( [employee_id] = 7 [emp_name] = Anantha Raman ) [1] => Array ( [employee_id] => 9 [emp_name] = Anith ) [2] = Array ( [employee_id] = 11 [emp_name] = Aravind ) });
我想检查 $schoolteachers 'empname',is in schoolgroup array($schoolgroup ['members'][''name]=Aravind) 并且只回显非成员我想显示基于名称的 $schoolteachers 数组,如果它不存在于$schoolgroups
我用的代码不好
foreach ($schoolteachers as $teachers) {
$classin = false;
foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($schoolgroups)) as $value) {
if ($value == $teachers['emp_name']) {
$classin = true;
break;
}
}
if (!$classin) {
echo $teachers['emp_name'];
}
}