-2
我想從this json文件中顯示以下值。
Titel的
datum_start
datum_end
我用這個代碼:用PHP解析JSON電視指南
<?php
$nl1jsonurl='http://www.tvgids.nl/json/lists/programs.php?channels=1';
$nl1jsontext=file_get_contents($nl1jsonurl,true);
$nl1 = json_decode($nl1jsontext);
foreach($nl1->1 as $data)
{
echo $data->titel . "\n";
echo $data->datum_start . "\n";
echo $data->datum_end . "\n";
}
?>
樣品JSON:
{
"1": [
{
"db_id": "14612024",
"titel": "NOS Journaal",
"genre": "Nieuws/actualiteiten",
"soort": "",
"kijkwijzer": "",
"artikel_id": null,
"artikel_titel": null,
"datum_start": "2013-07-05 00:10:00",
"datum_end": "2013-07-05 00:35:00"
},
{
"db_id": "14642893",
"titel": "NOS Studio Sportzomer: De Avondetappe",
"genre": "Sport",
"soort": "",
"kijkwijzer": "",
"artikel_id": "58162",
"artikel_titel": "Sprinten in Montpellier",
"datum_start": "2013-07-05 00:35:00",
"datum_end": "2013-07-05 01:30:00"
}
]
}
你質疑* iiiiis *? –
這裏有一個問號,就在第2行。問題是「php」。答案是肯定的。 – neokio
可能會給你stClass不能轉換爲字符串的錯誤,試試這個'$ nl1 = json_decode($ nl1jsontext,true);' – dakshbhatt21