我有这个(我只显示三个记录,还有很多很多)
Array
(
[0] => Array
(
[name] => Johnson, John
[telephonenumber] => 555.555.555
[department] => Department A
)
[1] => Array
(
[name] => Johnson, Bill
[telephonenumber] => 555.555.4444
[department] => Department B
)
[2] => Array
(
[name] => Johnson, Carry
[telephonenumber] => 555.555.3333
[department] => Department C
)
)
A、B等部门会有多个成员,我需要遍历这些数据,只吐出A部门的成员。我试过:
if ($phoneList['department'] == 'Falmouth') {
echo $phoneList['name'] . '<br>';
echo $phoneList['telephonenumber'] . '<br>';
echo $phoneList['department'] . '<br><br>';
}
但是我收到错误是因为我认为$phoneList['department']
不存在(不应该$phoneList[0]['department']
)?
无论哪种方式,这都无济于事......我如何搜索所有 90 个数组并只打印出具有 A 部门状态的数组?
$phoneList 是传递给我的视图的变量(使用 codeigniter、ldap 和 php)