웹프로그래밍

Global It Leader!!


PHP


 
 

기상청에서 내일과 모래 날씨 읽어오기

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 2,879회 작성일 18-01-04 23:33

본문

<?php

function file_get_contents_curl($url) {
    $ch = curl_init();// curl 리소스를 초기화
    curl_setopt($ch, CURLOPT_URL, $url); // url을 설정
    // 헤더는 제외하고 content 만 받음
    curl_setopt($ch, CURLOPT_HEADER, 0);
    // 응답 값을 브라우저에 표시하지 말고 값을 리턴
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    curl_close($ch);// 리소스 해제를 위해 세션 연결 닫음
    return $data;
}


$url = "http://www.kma.go.kr/wid/queryDFS.jsp?gridx=62&gridy=122";

$xml_string = file_get_contents_curl($url);

$xml = simplexml_load_string($xml_string);

$json = json_encode($xml); // XML to JSON

$R = json_decode($json,TRUE);//배열로 변환


print_r($R);

echo '<br />';

echo '<br />';

echo $R['header']['tm'].'<br />';//날씨 예보시간

$wData = $R['body']['data'][0];

print_r($wData);

echo '<br />';

echo '<br />';

//echo $wData['hour'].'시 온도:'.$wData['temp'].' 날씨:'.$wData['wfKor'];


foreach($R['body']['data'] as $wData){

    echo $wData['hour'].'시 온도:'.$wData['temp'].' 날씨:'.$wData['wfKor'];

    echo '<br />';

}

?> 

댓글목록

등록된 댓글이 없습니다.

전체 80
게시물 검색
PHP 목록
번호 제목 글쓴이 조회 날짜
40 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3552 01-23
39 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3484 06-25
38 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3474 07-01
37 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3468 10-19
36 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3460 08-28
35 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3199 11-11
34 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3177 02-22
33 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3165 12-31
32 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3076 12-09
31 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2902 09-29
30 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2886 06-23
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2880 01-04
28 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2854 04-07
27 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2793 09-23
26 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2739 02-22
25 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2721 08-29
24 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2719 10-22
23 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2652 09-21
22 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2632 08-06
21 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2630 05-14