PHP从Object访问数据

时间:2016-02-02 09:55:49

标签: php

我填写一个数组,当我输出以下

var_dump($users["JohnDoe"]);

我看到类似下面的内容

adLDAPUserCollection {#348 ▼
  #adldap: adLDAP {#287 ▶}
  #currentObject: null
  #info: array:2 [▼
    "count" => 1
    0 => array:17 [▼
      "telephonenumber" => array:2 [▼
        "count" => 1
        0 => "123456789"
      ]
      0 => "telephonenumber"
      "displayname" => array:2 [▼
        "count" => 1
        0 => "John Doe"
      ]
      1 => "displayname"
      "department" => array:2 [▼
        "count" => 1
        0 => "Some Department"
      ]
      2 => "department"
      "primarygroupid" => array:2 [▼
        "count" => 1
        0 => "123"
      ]
      3 => "primarygroupid"
      "objectsid" => array:2 [▼
        "count" => 1
        0 => b"\x01\x05\x00\x00\x00\x00\x00\x05\x"
      ]
      4 => "objectsid"
      "samaccountname" => array:2 [▼
        "count" => 1
        0 => "JohnDoe"
      ]
      5 => "samaccountname"
      "mail" => array:2 [▼
        "count" => 1
        0 => "JohnDoe@email.com"
      ]
    ]
  ]
}

现在我要做的是获得用户的部门。当我尝试以下

var_dump($users["JohnDoe"]->info[0]["department"][0]);

我返回null。我该如何获得这个用户部门?

由于

0 个答案:

没有答案