Home >Backend Development >PHP Tutorial >A program that displays weather forecast_PHP tutorial

A program that displays weather forecast_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:07:581079browse

When I first started learning PHP, I wrote a program and put it on my homepage, which can display the weather forecast. Of course, it is still very imperfect. I hope everyone can give me your opinions. The procedure is as follows:
$fcont=file("http://www.bjmb.gov.cn/today.asp");
$arr=array();
for ($i=0;$i $tmp=$fcont[$i];
$tmp=ereg_replace("
"," ", $tmp);
if(!strstr(strtolower($tmp),"img")){
$tmp=trim(strip_tags($tmp));
} else {
$st =ereg_replace("><",">⌒<",$tmp);
          $stt=split("⌒",$st); ; $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 $yb[]=$arr[$i];
}
?>



The originally obtained statement only needs to be executed once, and then the obtained data is compared with the old data to see whether it is new. If it is new, the old data is replaced. Otherwise, it is not replaced. There are rules to be found. Judge the time first. Generally, if it is one hour later than the forecast time, you can definitely get the latest forecast data. But I don’t think about it that much now, let’s talk about it later!

http://www.bkjia.com/PHPjc/315031.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315031.htmlTechArticleI just started learning PHP. I first wrote a program and put it on my homepage to display the weather forecast. Of course It's still far from perfect, so I hope you guys can give us your feedback. The program is as follows: ? $fcont=file(h...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn