日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

显示天气 php代码,天气预报查询示例代码

發布時間:2024/7/23 php 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 显示天气 php代码,天气预报查询示例代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey

$city = '安順';//utf8

$cityid='111';//任選

$citycode='101260301';//任選

$url = "https://api.jisuapi.com/weather/query?appkey=$appkey&city=$city";

$result = curlOpen($url, ['ssl'=>true]);

$jsonarr = json_decode($result, true);

//exit(var_dump($jsonarr));

if($jsonarr['status'] != 0)

{

echo $jsonarr['msg'];

exit();

}

$result = $jsonarr['result'];

echo $result['city'].' '.$result['cityid'].' '.$result['citycode'].' '.$result['date'].' '.$result['week'].' '.$result['weather'].' '.$result['temp'].'

';

echo $result['temphigh'].' '.$result['templow'].' '.$result['img'].' '.$result['humidity'].' '.$result['pressure'].' '.$result['windspeed'].' '.$result['winddirect'].'

';

echo $result['windpower'].' '.$result['updatetime'].'

';

echo '指數:

';

foreach($result['index'] as $index)

{

echo $index['iname'].' '.$index['ivalue'].' '.$index['detail']. '

';

}

echo '空氣質量指數:

';

$aqi = $result['aqi'];

echo $aqi['so2'].' '.$aqi['so224'].' '.$aqi['no2'].' '.$aqi['no224'].' '.$aqi['co']. '

';

echo $aqi['co24'].' '.$aqi['o3'].' '.$aqi['o38'].' '.$aqi['o324'].' '.$aqi['pm10']. '

';

echo $aqi['pm1024'].' '.$aqi['pm2_5'].' '.$aqi['pm2_524'].' '.$aqi['iso2'].' '.$aqi['ino2']. '

';

echo $aqi['ico'].' '.$aqi['io3'].' '.$aqi['io38'].' '.$aqi['ipm10'].' '.$aqi['ipm2_5']. '

';

echo $aqi['aqi'].' '.$aqi['primarypollutant'].' '.$aqi['quality'].' '.$aqi['timepoint']. '

';

echo $aqi['aqiinfo']['level'].' '.$aqi['aqiinfo']['color'].' '.$aqi['aqiinfo']['affect'].' '.$aqi['aqiinfo']['measure']. '

';

echo '未來幾天天氣:

';

foreach($result['daily'] as $daily)

{

echo $daily['date'].' '.$daily['week'].' '.$daily['sunrise'].' '.$daily['sunset']. '

';

echo $daily['night']['weather'].' '.$daily['night']['templow'].' '.$daily['night']['img'].' '.$daily['night']['winddirect'].' '.$daily['night']['windpower']. '

';

echo $daily['day']['weather'].' '.$daily['day']['templow'].' '.$daily['day']['img'].' '.$daily['day']['winddirect'].' '.$daily['day']['windpower']. '

';

}

echo '未來幾小時天氣:

';

foreach($result['hourly'] as $hourly)

{

echo $hourly['time'].' '.$hourly['weather'].' '.$hourly['temp'].' '.$hourly['img']. '

';

}

總結

以上是生活随笔為你收集整理的显示天气 php代码,天气预报查询示例代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。