提取多维数组的计数

时间:2017-11-10 19:44:54

标签: php arrays multidimensional-array

我有一个存储在$data中的ldap搜索的多维数组:

Array
(
    [count] => 1
    [0] => Array
        (
            [objectclass] => Array
                (
                    [count] => 3
                    [0] => top
                    [1] => posixGroup
                    [2] => sambaGroupMapping
                )

            [0] => objectclass
            [cn] => Array
                (
                    [count] => 1
                    [0] => xxxxx
                )

            [1] => cn
            [gidnumber] => Array
                (
                    [count] => 1
                    [0] => xxxx
                )

            [2] => gidnumber
            [sambasid] => Array
                (
                    [count] => 1
                    [0] => xxxx
                )

            [3] => sambasid
            [sambagrouptype] => Array
                (
                    [count] => 1
                    [0] => 2
                )

            [4] => sambagrouptype
            [displayname] => Array
                (
                    [count] => 1
                    [0] => xxxx
                )

            [5] => displayname
            [memberuid] => Array
                (
                    [count] => 2
                    [0] => xxxxx
                    [1] => xxxxx
                )

            [6] => memberuid
            [count] => 7
            [dn] => cn=xx,ou=xx,dc=xx,dc=xx
        )

)

我想提取memberuid的计数:[count] => 2但我无法正确执行此操作。我无法搞清楚结构......

我试过:$data[0]['displayname']['memberuid']['count']给了我一个Illegal string offset

感谢您的帮助

0 个答案:

没有答案