0
私のPHPの小屋のリターンエラーを取得することはできません。解析JSONは値
Undefined property: stdClass::$paging in Trying to get property of non-object Use of undefined constant total_items - assumed 'total_items' in
にはどうすればtotal_items
値を得ることができますか?
これはJSONです:このTyrの
{
"paging": {
"total_items": 0,
"current_page": 1,
"total_pages": 0
},
"data": [],
"facets": null
}
$content = file_get_contents($urll);
$clean_content = removeBomUtf8($content);
$decoded = json_decode($clean_content);
foreach ($decoded->data as $data)
{
$total_items = (string)$data->paging[0]->total_items;
echo total_items;
} ;
なぜ空の配列であれば、 '$ decoded-> data'をループしていますか?そしてそのjsonから 'total_items'値を得るには、' $ decoded-> paging-> total_items'だけのループがなくて済みます。 – ArtOsi