웹프로그래밍

Global It Leader!!


PHP


 
 

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

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 3,158회 작성일 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 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3800 04-11
39 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3769 01-23
38 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3769 12-31
37 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3747 06-25
36 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3685 07-01
35 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3667 08-28
34 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3445 03-26
33 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3404 11-11
32 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3391 02-22
31 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3316 12-09
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3159 01-04
29 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3131 06-23
28 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3114 09-29
27 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3050 04-07
26 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3010 02-22
25 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3009 09-23
24 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2933 10-22
23 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2915 08-29
22 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2877 03-30
21 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2873 05-14