2026, 새로운 도약을 시작합니다.

json 파일 (리스트) 목록 뿌려주기 채택완료

11개월 전 조회 1,745
Copy


{

    "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개

채택된 답변
+20 포인트
Copy










    

    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개

답변 감사합니다.
`/_

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고