繁体   English   中英

尝试使用PHP从JSON提取数据时获取通知

[英]Getting Notices while trying to fetch data from JSON Using PHP

我使用JSON提取了一些数据。 然后,我使用json_decode()将结果转换为PHP Array。 现在,我试图获得一些价值。 我正在收到通知。

$html = $curl->get($url);     // $html contains json result
$result = json_decode($html); //converting to php array
//the output is something like this
{
    "query":
        "results":{
           "Result":[
            {
              "BusinessUrl":"http://www.aplus.net/",
               -----------
               ------------
             }]
}

现在,如果我尝试像这样获取商户网址

$result->query->results->Result[0]->BusinessUrl

发出类似的通知

Notice: Trying to get property of non-object

请帮助我。

尝试

$ result->查询->结果->结果[0] ['BusinessUrl']

我的猜测是,一旦您在JSON中命中了数组,就无法访​​问数组而不是对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM