Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 谷歌天气API从F改为C_Php_Api_Google Weather Api - Fatal编程技术网

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'] ?>&deg; 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'] ?>&deg; F - <?= $forecast->high['data'] ?>&deg; 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;
}