weather.php code=='1'){ return false; } $data = $ip-data-city;return $data;}function getWeather($cityId){$url="http://www.weather.com.cn/data/sk/".$cityId.".html";$weather=json_decode(file_get_contents($url));return $weather;}function json_
code=='1'){
return false;
}
$data = $ip->data->city;
return $data;
}
function getWeather($cityId)
{
$url="http://www.weather.com.cn/data/sk/".$cityId.".html";
$weather=json_decode(file_get_contents($url));
return $weather;
}
function json_to_array($web){
$arr=array();
foreach($web as $k=>$w){
if(is_object($w)) $arr[$k]=json_to_array($w); //判断类型是不是object
else $arr[$k]=$w;
}
return $arr;
}
$city = getCity(getIP());
//$city = getCity('202.103.24.68');
//var_dump($city);die;
$city = str_split($city,strlen($city)-3);
$city =$city[0];
$cityUrl = "http://evenle.com/wei/20130921/city.php";
$web=json_decode(file_get_contents($cityUrl));
$arr=json_to_array($web);
$weatherInfo = getWeather($arr[$city]);
echo(json_encode($weatherInfo));
?>
