2011-11-09 13 views
0

気温を華氏から摂氏に変更するのに少し問題があります。Google天気APIのFからCへの変更

私の現在の気象度を変更したときにのみ正しく動作しますが、予測を変更していないときは正しく動作しません。

訴訟はありますか?

これは私のコードです。

<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 ?> 
+0

**、Googleの天気予報APIは2012年に閉鎖された** - > http://stackoverflow.com/questions/12145820/google-weather-api-gone/35943521 –

答えて

1
function toCelsius($deg) { 
    return ($deg-32)/1.8; 
} 

Fでの温度がここにある場合:$current[0]->temp_f['data']

次に、あなたがしなければならないすべてはこれです:toCelsius($current[0]->temp_f['data']