Beginner PHP, wrote a program to show the weather forecast, but also look not laughed at.

Source: Internet
Author: User
Tags array count learn php trim
Program | The weather forecast | Show just started to learn PHP, first compiled a program, on their own homepage, you can show the weather forecast, of course, still very imperfect, I hope everyone to give advice. 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 ("><", ">⌒<", $tmp);
$stt =split ("⌒", $st);
foreach ($stt as $key => $value) {
if (Strstr ($value, "img")) {
$tmp = $value;
$tmp =ereg_replace ("src=", "width=30 height=30 align=absmiddle src=http://www.163design.net/p/b/", $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+ "forecast </marquee>");
-->
</SCRIPT>
The statement that was obtained only needs to be executed once, then compares the acquired data with the old data, whether it is new, replaces the old data if it is new, and does not replace it. This is the law can be found, first judge time, generally than the forecast time of one hours later, certainly can get the latest forecast data. But now I don't think so much, later say it!

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.