我有這個(我只顯示三條記錄,還有很多很多)騎自行車通過關聯數組的數組
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個這樣的數組,並只打印出具有Department A狀態的數組?
$ PHONELIST被傳遞給我的看法變量(使用笨,LDAP和PHP)
迭代和檢查'department',還是我在這裏可以俯瞰什麼? – Josh
是的,那就是我正在做的......但是我正在使用=而不是==,並且它把所有東西都扔掉了!有時候我只需要寫點東西來解決它......感謝評論! – ClaytonDaniels