0

I have a JSON object, which i decoded with the php function json_decode. No i want to print a special value from the object:

echo $user[0]['mail'][0];

My problem is that i get such a return:

string(19) "example@hotmail.com"

I've filled up the json object with my ldap_search results. When i parse the JSON with js and print out the email, it looks fine, but with PHP not.

Edit:

array(2) { 
    ["count"]=>  int(1)  [0]=>  array(10) {   
        ["mail"]=>    array(2) {
            ["count"]=>      int(1)      [0]=>      string(23) "example@hotmail.com"
        } [0]=>    string(4) "mail"
        ["givenname"]=>    array(2) { 
            ["count"]=>      int(1)      [0]=>      string(5) "sylnois"
        } [1]=>    string(9) "givenname"
        ["sn"]=>    array(2) {
            ["count"]=>      int(1)      [0]=>      string(7) "bla"
        }    [2]=>    string(2) "sn"
        ["ou"]=>    array(2) {
            ["count"]=>      int(1)      [0]=>      string(4) "ZH"
        }    [3]=>    string(2) "ou"
        ["count"]=>    int(4)    ["dn"]=>    string(24) "SOME_DN"  }}
4

1 回答 1

1
$json = '{"user_name":"admin","0":{"email":{"0":"admin@gmail.com"}},"count":5}';


$user = json_decode($json,true);

echo $user[0]['email'][0];

 Rusult : admin@gmail.com
于 2013-03-01T13:37:58.053 回答