php解析中国天气网返回的json天气数据
中国天气网返回的json数据如下{"weatherinfo":{"city":"上海","cityid":"101200201","temp1":"25℃","temp2...
中国天气网返回的json数据如下
{"weatherinfo":{"city":"上海","cityid":"101200201","temp1":"25℃","temp2":"19℃","weather":"小雨转阵
雨","img1":"d7.gif","img2":"n3.gif","ptime":"11:00"}}
如何通过php解析得到“上海天气:小雨转阵雨,气温19℃-25摄氏度” ?谢谢了 展开
{"weatherinfo":{"city":"上海","cityid":"101200201","temp1":"25℃","temp2":"19℃","weather":"小雨转阵
雨","img1":"d7.gif","img2":"n3.gif","ptime":"11:00"}}
如何通过php解析得到“上海天气:小雨转阵雨,气温19℃-25摄氏度” ?谢谢了 展开
2个回答
展开全部
$jsondata ;
$data = json_decode($jsondata);
$city = $data['weatherinfo']['city'];//上海
$weather = $data['weatherinfo']['weather'];//小雨转阵
雨
$temp1 = $data['weatherinfo']['temp1'];//25°C
$temp2 = $data['weatherinfo']['temp2'];//19°C
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询