Home >Backend Development >PHP Tutorial >A program that displays weather forecast_PHP tutorial
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=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
}
?>
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!