A program for displaying weather forecasts

Source: Internet
Author: User

When I first started learning PHP, I first compiled a program and placed it on my home page to display the weather forecast. Of course, it is still not perfect. I hope you can give me some comments. The procedure is as follows:
<?
$ Fcont = file ("http://www.bjmb.gov.cn/today.asp ");
$ Arr = array ();
For ($ I = 0; $ I <count ($ fcont); $ I ++ ){
$ Tmp = $ fcont [$ I];
$ Tmp = ereg_replace ("<br>", "", $ tmp );
If (! Strstr (strtolower ($ tmp), "img ")){
$ Tmp = trim (strip_tags ($ tmp ));
} Else {
$ St = ereg_replace ("> <", "> replace <", $ tmp );
$ Stt = split ("shard", $ st );
Foreach ($ stt as $ key => $ value ){
If (strstr ($ value, "img ")){
$ Tmp = $ value;
$ Tmp = ereg_replace ("src =", "width = 30 height = 30 align = absmiddle src =", $ tmp );
If (strstr ($ tmp, "bt9.jpg") | strstr ($ tmp, "colline.gif") $ tmp = "";
}
}
}
If (trim ($ tmp )! = "" & Trim ($ tmp )! = "") $ Arr [] = $ tmp;
}
$ Yb = array ();
For ($ I = 2; $ I <count ($ arr)-6; $ I ++ ){
$ Yb [] = $ arr [$ I];
}
?>
<Br>
<Script language = "JavaScript">
<! --
Syb = "";
<?
$ Exp = "-3-7-9-14-18-20-25 -";
For ($ I = 1; $ I <count ($ yb); $ I ++ ){
If (! Strstr ($ exp, "-". (string) ($ I + 1 )."-")){
?>
Syb = syb + '<? = $ Yb [$ I];?> ';
<?}}?>
Document. write ("<? = $ Yb [0]?> "+ ":");
Document. write ("<marquee width = 400 align = middle scrollamount = 5 scrolldelay = 200>" + syb + "prediction </marquee> ");
// -->
</SCRIPT>
The previously obtained statement only needs to be executed once. Then, compare the obtained data with the old data to determine whether it is new. If it is new, replace the old data. Otherwise, do not replace it. This is a regular search. First, judge the time. Generally, if it is one hour later than the forecast time, you can certainly get the latest forecast data. But now I have not considered that much. Let's talk about it later!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.