# Lấy bảng dự báo thời tiết


Dễ lắm :D Ngày xửa ngày xưa thì dùng đoạn Javascript của bên Vnexpress.net. Nhưng giờ ít ai dùng cái đó nữa vì nó quá đơn giản. Thế nên sẽ lấy ở các nguồn khác thôi. Chung quy lại, là nên lấy của thằng Trung tâm khí tượng thủy văn Việt Nam (http://www.nchmf.gov.vn) là chuẩn nhất (chuyện, của Việt Nam mà :p)

/\*\*
 \* Get weather table
 \* @author Do Nam Khanh
 \* @return string
 \*/
function \_weather() {
    $content = file\_get\_contents('http://www.nchmf.gov.vn/website/vi-VN/43/Default.aspx');

    $strBegin = '<!-- Begin Display content -->';
    $strEnd = '<TD class="thoitiet\_rightbox\_ver"></TD>';

    $pos1 = strpos($content, $strBegin);

    if(false === $pos1) {
        return '';
    }

    $pos2 = strpos($content, $strEnd);
    $content = substr($content, $pos1, ($pos2-$pos1));
    
    return strip\_tags($content, '<table><tr><td><img>');
}

Demo: [http://halongtours.vn/demo](http://halongtours.vn/demo)

