1
'data.json'파일에서 json 형식으로 데이터를 인쇄하려고합니다. 내 PHP 파일 (alldata.php), 나는 모든 데이터 (배열) 꽤 인쇄 얻을 수 있습니다. 하지만 특정 배열 이름을 가져 오는 방법과 객체/내용을 얻는 방법을 알려주고 싶습니다.URL에서 배열 이름을 파싱하여 JSON 파일에서 데이터를 가져 오는 방법
내 alldata.php은 다음과 같습니다 : 나는 그런 '? alldata.php 검색 = 선수 으로 URL을 사용하여 콘텐츠를 예를 들어 "선수"배열을 얻을 수있는 방법
PHP에서{
"players": [
{
"name": "Marcos Alonso",
"position": "Left-Back",
"nationality": "Spain",
"marketValue": "9,000,000 €",
"created": "2017-04-15 10:04:58"
}],
"articles": [
{
"author": "Stephen Walter",
"title": "Disruptive stag party revellers thrown off plane at Manchester Airport",
"url": "http://www.telegraph.co.uk/news/2017/04/15/disruptive-stag-party-revellers-thrown-plane-manchester-airport/",
"publishedAt": "2017-04-15T09:25:10Z"
}],
land": [
{
"state": "Somewhr",
"found": "1889",
"area": "6,812",
"empl": "1,325",
"ppl": "16,842"
}]
}
, 여기에 코드 샘플 ....
//get content of the JSON API using file_get_contents()
$url = ('myJson.json');
$jsondata = file_get_contents($url);
//convert json object to php associative array
$data = json_decode($jsondata, true);
what do I do here to query the data.json file for a specific array?????
header('Content-Type: application/json; charset=UTF-8');
$json_string = json_encode($????????????, JSON_PRETTY_PRINT);
print $json_string;
덕분이다
이 배열은 항상 여러 데이터 (같은 나무)와 같은를 찾고? – OldPadawan