json 디코드 결과에서 배열 데이터를 에코하려는 경우 file_get_contents와 curl을 모두 시도해 보았습니다. json 디코드에서 배열 데이터를 에코합니다.
이
여기 .. 지금{"Servers": {
"lastChangedDate": null,
"ServersList": [
{
"online": "The server is UP",
"offline": "The server is DOWN",
"maintainace": "The server is currently in maintenance mode",
"location": "EU",
"ip": "x.x.x.x"
},
{
"online": "The server is UP",
"offline": "The server is DOWN",
"maintainace": "The server is currently in maintenance mode",
"location": "US",
"ip": "x.x.x.x"
}
]
}}
다음 출력을 디코딩 한 후에 이런 배열 될 것이다 ..
Array (
[Servers] => Array (
[lastChangedDate] =>
[ServersList] => Array (
[0] => Array (
[online] => The server is UP
[offline] => The server is down
[maintenance] => The server is currently in maintenance mode
[location] => EU
[ip] => x.x.x.x
)
[1] => Array (
[online] => The server is UP
[offline] => The server is DOWN
[maintenance] => The server is currently in maintenance mode
[location] => US
[ip] => x.x.x.x
)
)
)
)
I는 JSON 출력되는 서버로부터 얻는 반응이다 내 PHP 코드
<?php
$request = file_get_contents("test.json");
$input = json_decode($request, true);
echo $input['Servers']['lastChangedDate']['ServersList'][0]['online'];
?>
데모 with print_r ($ input); 대신 내 메인 페이지에 따라서 http://phpad.org/run/1666334020
에코의 난 당신이 위의 게시 된 JSON에서이 http://codepen.io/anon/pen/jEEPMG.html
'$ 입력 [ '서버는'] [ 'ServersList'] [0] [ '온라인'] '사람을 작동 – Fractaliste
작동합니다 .. 고마워 .. 대답으로 게시하여 답변으로 표시 할 수있었습니다. – skyline33
print_r 출력은 올바르게 표시하면 들여 쓰기됩니다. 선 아래로 들여 쓰기를 따라 가세요. –