"101010300");foreach ($citycode as $arr => $value) {$citycode[$arr] = "http://wea">
时间:2021-07-01 10:21:17 帮助过:20人阅读
foreach ($citycode as $arr => $value) {
$citycode[$arr] = "http://weather.xxx.com/".substr($citycode[$arr], 3,4).".txt";
//$citycode[$arr] .= "http://weather.xxx.com/".$citycode[$arr].".txt";
}
$citycode[$arr.'1'] = "http://weather.xxx.com/".substr($citycode[$arr], 3,4).".txt";
$citycode = array(
"北京"=>"101010100",
"朝阳"=>"101010300"
);
$tmp = array();
foreach ($citycode as $arr => $value) {
$tmp[] = "http://weather.xxx.com/".substr($value, 3,4).".txt";
$tmp[] = "http://weather.xxx.com/".$value.".txt";
}
echo implode("\r\n", $tmp);
//saveFile('api/weather.txt',implode("\r\n",$citycode));
http://weather.xxx.com/0101.txt
http://weather.xxx.com/101010100.txt
http://weather.xxx.com/0103.txt
http://weather.xxx.com/101010300.txt
$citycode = array(
"北京"=>"101010100",
"朝阳"=>"101010300"
);
$result = array();
foreach ($citycode as $arr => $value) {
array_push($result,"http://weather.xxx.com/".substr($value, 3,4).".txt");
array_push($result,"http://weather.xxx.com/".$value.".txt");
}
/*
功能:按行保存为文件
*/
saveFile('api/weather.txt',implode("\r\n",$result));