我一直在PHP中製作一個IRC bot。我爲0到5之間的不同用戶提供了特定的訪問級別.0是來賓,5是管理員。通過多維關聯數組循環遍歷
我一直在試圖編寫一個命令,當用戶訪問它時,它會向它們發送一個允許使用的命令和語法列表。
到目前爲止,我有這樣的事情
$array = array
(
"5" => $commands = array
(
"test" => $test2 = array
(
"trigger" => "!test",
"descrip" => "Just testing."
)
"test2" => $test3 = array
(
"trigger" => "!lol",
"descrip" => "another test."
)
)
);
我不知道如何通過其循環,使if ($accessLevel == 5) then show commands for $array[5(and below)]
最後我希望它送出去$array[5][command][trigger] : $array[5][command][descrip]
我不不一定需要你爲我編寫代碼,只要朝正確的方向推進就會有所幫助。
我絕對喜歡使用數組標記的想法。這使它更清潔。讓我試試這個報告。 – Rob 2011-01-24 18:45:24