$ GLOBALS的in_array问题

时间:2010-09-23 21:12:05

标签: php arrays globals

我有一个$GLOBALS['plugins']数组。有了这些价值观:

Array
(
    [0] => Array
    (
        [0] => calendarFuncs/
        [1] => calendar.php 
        [2] => Calendar
    )
    [1] => Array
    ( 
        [0] => eventFuncs/ 
        [1] => todo.php 
        [2] => Projects
    )
    [2] => Array
    (
        [0] => financeFuncs/ 
        [1] => finance.php 
        [2] => Finances 
    )
    [3] => Array
    ( 
        [0] => crmFuncs/ 
        [1] => crm.php 
        [2] => CRM
    )
    [4] => Array
    ( 
        [0] => adminFuncs/ 
        [1] => admin.php 
        [2] => Admin
    )
)

返回false,总是......

in_array('Projects', $GLOBALS['plugins'])

有什么想法吗?

谢谢。

1 个答案:

答案 0 :(得分:2)

in_array()不会通过多维数组递归搜索。

您可以遍历$GLOBALS['plugins']数组并在内部的每个项目上执行in_array()