curl json 질문좀 드릴게요 채택완료
익수야가자
4년 전
조회 1,835
curl 로 데이터를 받아오니
{"410873":{"charge":"80.00","start_count":"116","status":"Completed","remains":"0","currency":"KRW"},"410874":{"charge":"80.00","start_count":"241","status":"Completed","remains":"0","currency":"KRW"},"410903":{"charge":"0.00","start_count":null,"status":"Canceled","remains":"100","currency":"KRW"}}
데이터들이 이렇게 표시가 되는데
각각 함수에 담아서 echo로 표시하고싶습니다.
허나 방법을 잘 모르겠습니다.
$response = curl_exec($curl);
$tmp=json_decode($response);
이렇게 echo 찍어보니 Array 라고만 나오고
echo $response['charge']; echo $tmp['charge'] 이렇게 찍어봐도 아무것도 나오지 않는데 도와주실 분 계신가요?
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
4년 전
각각 객체들 charge 출력방법입니다.
</p>
<p>$response = curl_exec($curl);</p>
<p>$tmp=json_decode($response,true);</p>
<p>foreach($tmp as $key => $val){</p>
<p> echo $tmp[$key]['charge']."
";</p>
<p>}</p>
<p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 3개
�
익수야가자
4년 전
�
익수야가자
4년 전
var_dump 시
object(stdClass)#10 (3) { ["410873"]=> object(stdClass)#6 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "116" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410874"]=> object(stdClass)#11 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "241" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410903"]=> object(stdClass)#12 (5) { ["charge"]=> string(4) "0.00" ["start_count"]=> NULL ["status"]=> string(8) "Canceled" ["remains"]=> string(3) "100" ["currency"]=> string(3) "KRW" } } object(stdClass)#10 (3) { ["410873"]=> object(stdClass)#6 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "116" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410874"]=> object(stdClass)#11 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "241" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410903"]=> object(stdClass)#12 (5) { ["charge"]=> string(4) "0.00" ["start_count"]=> NULL ["status"]=> string(8) "Canceled" ["remains"]=> string(3) "100" ["currency"]=> string(3) "KRW" } } object(stdClass)#10 (3) { ["410873"]=> object(stdClass)#6 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "116" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410874"]=> object(stdClass)#11 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "241" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410903"]=> object(stdClass)#12 (5) { ["charge"]=> string(4) "0.00" ["start_count"]=> NULL ["status"]=> string(8) "Canceled" ["remains"]=> string(3) "100" ["currency"]=> string(3) "KRW" } }
이렇게 출력이 되고 있구요
object(stdClass)#10 (3) { ["410873"]=> object(stdClass)#6 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "116" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410874"]=> object(stdClass)#11 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "241" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410903"]=> object(stdClass)#12 (5) { ["charge"]=> string(4) "0.00" ["start_count"]=> NULL ["status"]=> string(8) "Canceled" ["remains"]=> string(3) "100" ["currency"]=> string(3) "KRW" } } object(stdClass)#10 (3) { ["410873"]=> object(stdClass)#6 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "116" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410874"]=> object(stdClass)#11 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "241" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410903"]=> object(stdClass)#12 (5) { ["charge"]=> string(4) "0.00" ["start_count"]=> NULL ["status"]=> string(8) "Canceled" ["remains"]=> string(3) "100" ["currency"]=> string(3) "KRW" } } object(stdClass)#10 (3) { ["410873"]=> object(stdClass)#6 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "116" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410874"]=> object(stdClass)#11 (5) { ["charge"]=> string(5) "80.00" ["start_count"]=> string(3) "241" ["status"]=> string(9) "Completed" ["remains"]=> string(1) "0" ["currency"]=> string(3) "KRW" } ["410903"]=> object(stdClass)#12 (5) { ["charge"]=> string(4) "0.00" ["start_count"]=> NULL ["status"]=> string(8) "Canceled" ["remains"]=> string(3) "100" ["currency"]=> string(3) "KRW" } }
이렇게 출력이 되고 있구요
�
익수야가자
4년 전
죄송합니다 제가 true를 빼먹었네요..ㅎㅎ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
이렇게 오류창이 나옵니다