dounue1965 2014-06-15 18:28
浏览 12

在JSON中显示结果到PHP [重复]

<?php 
include_once("zillow_api.php");
$zws_id = "*****************";
$zillow_api = new Zillow_Api($zws_id); // $zws_id is your Zillow API Key
$search_result = $zillow_api->GetSearchResults(array('address' => '7356 CARTER AVE',     'citystatezip' => 'NEWARK'));

$data = json_decode( json_encode($search_result) , 1);
var_dump($data);

print_r($data->request);


?>

Above PHP Code

Here is the result:

array(3) { ["request"]=> array(2) { ["address"]=> string(15) "7356 CARTER AVE" ["citystatezip"]=> string(6) "NEWARK" } ["message"]=> array(2) { ["text"]=> string(30) "Request successfully processed" ["code"]=> string(1) "0" } ["response"]=> array(1) { ["results"]=> array(1) { ["result"]=> array(5) { ["zpid"]=> string(8) "52932643" ["links"]=> array(4) { ["homedetails"]=> string(80) "zillow.com/homedetails/7356-Carter-Ave-Newark-CA-94560/52932643_zpid/" ["graphsanddata"]=> string(96) "zillow.com/homedetails/7356-Carter-Ave-Newark-CA-94560/52932643_zpid/#charts-and-data" ["mapthishome"]=> string(42) "http://www.zillow.com/homes/52932643_zpid/" ["comparables"]=> string(48) "http://www.zillow.com/homes/comps/52932643_zpid/" } ["address"]=> array(6) { ["street"]=> string(15) "7356 Carter Ave" ["zipcode"]=> string(5) "94560" ["city"]=> string(6) "Newark" ["state"]=> string(2) "CA" ["latitude"]=> string(9) "37.529165" ["longitude"]=> string(11) "-122.039157" } ["zestimate"]=> array(6) { ["amount"]=> string(6) "703264" ["last-updated"]=> string(10) "06/12/2014" ["oneWeekChange"]=> array(1) { ["@attributes"]=> array(1) { ["deprecated"]=> string(4) "true" } } ["valueChange"]=> string(5) "23695" ["valuationRange"]=> array(2) { ["low"]=> string(6) "668101" ["high"]=> string(6) "738427" } ["percentile"]=> string(1) "0" } ["localRealEstate"]=> array(1) { ["region"]=> array(2) { ["@attributes"]=> array(3) { ["id"]=> string(5) "49611" ["type"]=> string(4) "city" ["name"]=> string(6) "Newark" } ["links"]=> array(3) { ["overview"]=> string(51) "zillow.com/local-info/CA-Newark/r_49611/" ["forSaleByOwner"]=> string(37) "zillow.com/newark-ca/fsbo/" ["forSale"]=> string(32) "zillow.com/newark-ca/" } } } } } } } 

I want to show result in php

print_r($data->response->result->zpid); // i use this what getting error 

Notice: Trying to get property of non-object in E:\xampp\htdocs\work\zillow\zillow.php on line 14

</div>
  • 写回答

1条回答 默认 最新

  • douzhang7184 2014-06-15 18:59
    关注

    This is your code:

    $data = json_decode( json_encode($search_result) , 1);
    

    Change your code like that(replace true to 1)

    $data = json_decode( json_encode($search_result) , true);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数