我正在尝试从API访问json数据,并暂时将其显示在网页上。我能够获取数据数组,但我想在该数据中只有1个字段。以下是我的代码。
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'ACCEPT: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL,"https://www.localmed.com/providers/us_0651651651_9vg5u1r2g1tw3e5_f24c866/openings/?reasonForVisitId=us_1223_new_teethcleaning-adult");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
curl_close($ch);
//$json_a=json_decode($result,true);
var_dump(json_decode($result, true));
var_dump ($result[1]['time']);
以下是结果,
我只需要时间'领域。请帮忙。我收到错误未定义索引'时间'
array (size=1)
'openings' =>
array (size=10)
0 =>
array (size=4)
'id' => string 'us_0651651651_9vg5u1r2g1tw3e5_f24c866_20160909T130000Z_67cbe00' (length=62)
'uri' => string '/providers/us_0651651651_9vg5u1r2g1tw3e5_f24c866/openings/us_0651651651_9vg5u1r2g1tw3e5_f24c866_20160909T130000Z_67cbe00/' (length=121)
'display' => null
'time' => string '2016-09-09T13:00:00Z' (length=20)