json 파일 (리스트) 목록 뿌려주기 채택완료
{
"status": "200",
"api_mid": "1",
"totalRecord": "3",
"data": [
{
"no": 1,
"test_key": "12",
"test_name": "첫번째 항목",
"test_company": "123",
"test_thum_url": "https:\/\/test.com\/data\/2025\/02\/05\/1738748071_사과.jpg",
"test_file_url": "https:\/\/test.com\/data\/2025\/02\/05\/1738748071_참외.jpg",
"test_file_size": ""
},
{
"no": 2,
"test_key": "5",
"test_name": "두번째 항목",
"test_company": "123",
"test_thum_url": "",
"test_file_url": "",
"test_file_size": ""
},
{
"no": 3,
"test_key": "10",
"test_name": "세번째 항목 ",
"test_company": "",
"test_thum_url": "https:\/\/test.com\/data\/2025\/02\/05\/1738746852_수박.jpg",
"test_file_url": "https:\/\/test.com\/data\/2025\/02\/05\/1738746852_딸기.jpg",
"test_file_size": ""
}
]
}
위와같이 json방식으로 뿌려주는 URL이 있을경우 어떻게 리스트(목록)을 보여지게 하는지요?
3개의 데이터를 리스트 형태로 보여주고싶습니다.
------------ URL을 읽어와서 JSON으로 뿌려지는것까지는 구현했습니다 ----
$url = "----제공된 URL ----";
$json_data = json_encode($data, true);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$response = curl_exec($ch);
$result = json_decode($response, true);
$result = iconv("EUC-KR", "UTF-8", $response);
print_r($response);
curl_close($ch);
답변 2개
JSON 데이터 목록
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f4f4f4; }
img { max-width: 100px; height: auto; }
JSON 데이터 목록
No
Test Key
Test Name
Test Company
Thumbnail
File URL
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
이미 배열로 만드셨네요.
$response['data']안에 목록들의 행이 있기때문에
for, foreach등을 사용하여 루프돌리시면됩니다.
답변에 대한 댓글 2개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
이렇게 긴 코딩까지 직접 해주실줄은...
정말 감사합니다.