jsonの読み取りに問題があります
私はこれを私のjsonの読み取りに使用します:
$json = file_get_contents($url);
$data = json_decode($json, true);
ここに私のjsonがあります:
{"metadata":
{
"name":"OurDatabase",
"articles":[
{"id":1,
"url":"http://www.google.com","title":"google.com",
"image":"http://www.oursite/e34ffadf12cd303dc7ba7e4a.jpg",
"category":[3]},
{"id":2,
"url":"http://www.google.com","title":"google.com",
"image":"http://www.oursite/e34ffadf12cd303dc7ba7e4a.jpg",
"category":[6]}
]
}
各記事のタイトルとIDを回復するために複数のコンビナゾンを試しました:私は近いと思います...
foreach ($data as $value) {
$id = $data[0]['articles'][$i]['id'];
$titre = $data[$i]['articles']['articles'][0]['title'];
}
しかし..何も機能しません.私を助けてもらえますか? どうもありがとう