여기에 내 모든 JSON 데이터에 대해 NULL이 표시됩니다.
$jsons1 = file_get_contents($api_url); // returns JSON
$jsons=json_decode($jsons1);
foreach ($jsons as $json)
{
echo "\n";
echo "<ul>";
echo "<li>";
echo "\nTitle : ".$json->title."\n";
echo "\nContent: ".$json->content."\n";
echo "</li>";
echo "</ul>";
}
$ json-> title처럼 가져올 수 없습니다. 뭔가 빠졌나요?
출력은
- Title : Content:
이와 관련하여 도와주세요
다음은 $jsons1
변수의 출력입니다.
{"results":[{"title": "Temp, Russia - Wikipedia, the free encyclopedia","kwic": "Coordinates : 52°03′N 39°44′E  /  52.05°N 39.733°E  / 52.05; 39.733 tenmp ( Russian : УÑмань ) is a town and the administrative center of ...","content": "","url": "http://en.wikipedia.org/wiki/sdfds,_Russia","iurl": "","domain": "en.wikipedia.org","author": "","news": false,"votes": "1","date": 1357744155518,"related":[]}],"query": "tenp","suggestions":[],"count":96,"start":1,"length":10,"time": "412"}
데이터가 포함 된 개체 결과가 있습니다.
따라서 Foreach 문을 수정하면됩니다 ..>
foreach ($jsons->results as $json) { ... }
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다