I am trying to access the json data from an API, and displaying it on the webpage for the time being. I am able to fetch the data array, but I want only 1 field in that data. Below is my code.
$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']);
Below are the results,
I need to get only the 'time' field. please help. I am getting error undefined index '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)