Есть код.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.rasp.yandex.net/v1.0/schedule/?apikey=token&format=json&uid=038AA_tis&station=s9616993&lang=ru&thread=false");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
$json=json_decode($response,true);
?>
<?php
$products=json_decode($response,true);
foreach ($products as $key => $value) {
echo "<table class='mytable'>";
foreach ($value as $k=> $v) {
echo "<tr><td><br>".$k."</td><td></td></tr>";
foreach ($v as $g=> $l) {
$g=str_replace ('except_days','Кроме дней:',$g);
$g=str_replace ('uid','Идентификатор:',$g);
$g=str_replace ('start_time','Время начала:',$g);
$g=str_replace ('title','город прибытия:',$g);
$g=str_replace ('short_title','Направление:',$g);
$g=str_replace ('departure_time','Время отъезда:',$g);
$g=str_replace ('platform','Платформа:',$g);
$g=str_replace ('arrival_time','Время прибытия:',$g);
$g=str_replace ('days','По дням:',$g);
$g=str_replace ('is_fuzzy','',$g);
$g=str_replace ('stops','Остановки:',$g);
$g=str_replace ('terminal','терминал:',$g);
$g=str_replace ('thread','Шаг:',$g);
echo "<tr><td>".$g."</td><td>".$l."</td></tr>";
}
}
echo "</table>";
}
?>
Не могу вывести все значения, вот ответ json
{"date":null,"pagination":{"has_next":false,"per_page":100,"page_count":1,"total":5,"page":1},"station":{"code":"s9616993","station_type":"вокзал","title":"Керчь","popular_title":"","short_title":"","transport_type":"train","type":"station"},"event":"departure","schedule":[{"except_days":null,"thread":{"carrier":{"code":8459,"codes":{"icao":null,"sirena":null,"iata":null},"title":"ГУП РК \"Крымская железная дорога\""},"transport_type":"suburban","uid":"6746_0_9616993_g16_4","title":"Керчь - Джанкой","vehicle":null,"number":"6746","short_title":"Керчь - Джанкой","express_type":null},"platform":"","arrival_time":null,"days":"ежедневно","stops":"кроме: 57 км","terminal":null,"is_fuzzy":false,"departure_time":"08:20"},{"except_days":null,"thread":{"carrier":{"code":8459,"codes":{"icao":null,"sirena":null,"iata":null},"title":"ГУП РК \"Крымская железная дорога\""},"transport_type":"train","uid":"562S_0_2","title":"Ростов-на-Дону - Симферополь","vehicle":null,"number":"562С","short_title":"Ростов-на-Дону - Симферополь","express_type":null},"platform":"","arrival_time":"10:30","days":"по чётным по 30.01","stops":"","terminal":null,"is_fuzzy":false,"departure_time":"10:35"},{"except_days":null,"thread":{"carrier":{"code":8459,"codes":{"icao":null,"sirena":null,"iata":null},"title":"ГУП РК \"Крымская железная дорога\""},"transport_type":"suburban","uid":"6742_0_9616993_g16_4","title":"Керчь - Джанкой","vehicle":null,"number":"6742","short_title":"Керчь - Джанкой","express_type":null},"platform":"","arrival_time":null,"days":"ежедневно","stops":"кроме: 57 км","terminal":null,"is_fuzzy":false,"departure_time":"14:20"},{"except_days":null,"thread":{"carrier":{"code":8459,"codes":{"icao":null,"sirena":null,"iata":null},"title":"ГУП РК \"Крымская железная дорога\""},"transport_type":"train","uid":"562YE_0_2","title":"Симферополь - Ростов-на-Дону","vehicle":null,"number":"562Э","short_title":"Симферополь - Ростов-на-Дону","express_type":null},"platform":"","arrival_time":"16:08","days":"по чётным по 30.01","stops":"","terminal":null,"is_fuzzy":false,"departure_time":"16:13"},{"except_days":null,"thread":{"carrier":{"code":8459,"codes":{"icao":null,"sirena":null,"iata":null},"title":"ГУП РК \"Крымская железная дорога\""},"transport_type":"suburban","uid":"6744_0_9616993_g16_4","title":"Керчь - Джанкой","vehicle":null,"number":"6744","short_title":"Керчь - Джанкой","express_type":null},"platform":"","arrival_time":null,"days":"ежедневно","stops":"кроме: 57 км, 13 км","terminal":null,"is_fuzzy":false,"departure_time":"20:45"}]}
Мне нужно получить значения:
except_days
title
short_title
departure_time
arrival_time
days
stops
Помогите поправить код, чтобы левые данные не вылазили, а те которые показал высвечивались. Уже голову всю сломал. Заранее спасибо
Вопрос решен всем спасибо