Hello friends I am trying reading this json in php but I don´t get to extract the data correctly
I try this and works
echo $jsonencode->extractordata->url;
echo $jsonencode->extractordata->resourceid;
I want to extract information that it is in data array I try this but it doesn´t work It show me error
echo $jsonencode->extractordata->data->group->hora;
This is the proper way to traverse your JSON:
$json = file_get_contents($url);
$data = json_decode($json);
if (empty($data->extractorData->data)) {
die("Invalid data
");
}
foreach ($data->extractorData->data as $d) {
if (!is_array($d->group) || !is_array($d->group))
continue;
foreach ($d->group as $group) {
if (!isset($group->Hora) || !is_array($group->Hora))
continue;
foreach ($group->Hora as $hora) {
if (!isset($hora->text))
continue;
echo "$hora->text
";
}
}
}
Sample Output
01:00 CET
01:30 CET
01:30 CET
02:00 CET
02:30 CET
04:30 CET
...
$jsonencode->extractorData->data[0]->group[0]->Hora
The "data" property is an array.