努力从存储在 php 变量中的这个复杂的 json 中提取必要的数据。
通过php脚本,我调用了yql。数据返回并分配给 $retarr;
然后再往下, $retarr[2] 正在存储完整的值,如下所示:
$debugarrays= print_r($retarr[2], true);
echo "<pre>";
echo $debugarrays;
echo "</pre>";
cbfunc({
"query":{
"count":10,
"created":"2012-06-13T09:13:45Z",
"lang":"en-US",
"results":{
"contact":[
{
"created":"2006-10-29T04:32:07Z",
"updated":"2006-10-29T04:32:07Z",
"uri":"http://social.yahooapis.com/v1/user/MNQJOMYDQYLY2FZSMROV4QDA6MI/contact/12",
"isConnection":"false",
"id":"12",
"fields":[
{
"created":"2006-10-29T04:32:07Z",
"updated":"2006-10-29T04:32:07Z",
"uri":"http://social.yahooapis.com/v1/user/MNQJOMYDQYLY2FZSMROV4QDA6MI/contact/12/email/6",
"id":"6",
"type":"email",
"value":"jaq@lifemastr.com",
"editedBy":"OWNER"
},
{
"created":"2006-10-29T04:32:07Z",
"updated":"2006-10-29T04:32:07Z",
"uri":"http://social.yahooapis.com/v1/user/MNQJOMYDQYLY2FZSMROV4QDA6MI/contact/12/name/5",
"id":"5",
"type":"name",
"value":{
"givenName":"'Jaq'",
"middleName":null,
"familyName":null,
"prefix":null,
"suffix":null,
"givenNameSound":null,
"familyNameSound":null
},
"editedBy":"OWNER"
}
]
}
]
}
}
});
$sJson= $retarr[2];
$aNative = json_decode($sJson);
print_r($aNative);
echo $retarr[2]->fields[0]->id."<br>";
echo $retarr[2]->fields[0]->type."<br>";
echo $retarr[2]->fields[0]->value."<br>";
未能获得所需的值...