Php 谷歌天气API从F改为C
我在把气温从华氏度调到摄氏度时遇到了点麻烦 只有当我改变了当前的天气等级,而不是当我改变了天气预报时,它才能正常工作 有什么建议吗 这是我的密码Php 谷歌天气API从F改为C,php,api,google-weather-api,Php,Api,Google Weather Api,我在把气温从华氏度调到摄氏度时遇到了点麻烦 只有当我改变了当前的天气等级,而不是当我改变了天气预报时,它才能正常工作 有什么建议吗 这是我的密码 <h2>Today's weather</h2> <div class="weather"> <img src="<?= 'http://www.google.com' . $current[0]->icon['data']?>" alt=
<h2>Today's weather</h2>
<div class="weather">
<img src="<?= 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather"?>
<span class="condition">
<?= $current[0]->temp_f['data'] ?>° F,
<?= $current[0]->condition['data'] ?>
</span>
</div>
<h2>Forecast</h2>
<? foreach ($forecast_list as $forecast) : ?>
<div class="weather">
<img src="<?= 'http://www.google.com' . $forecast->icon['data']?>" alt="weather"?>
<div><?= $forecast->day_of_week['data']; ?></div>
<span class="condition">
<?= $forecast->low['data'] ?>° F - <?= $forecast->high['data'] ?>° F,
<?= $forecast->condition['data'] ?>
</span>
</div>
<? endforeach ?>
今天的天气
图标['data']?>“alt=”天气“?>
&华氏度,
预测
图标['data']?>“alt=”天气“?>
&度;F-°;F
如果您的温度以F表示:$current[0]>temp\u F['data']
那么你所要做的就是:toCelsius($current[0]->temp\u f['data']]
谷歌天气API在2012年关闭->
function toCelsius($deg) {
return ($deg-32)/1.8;
}