2011-11-09 3 views
0

날씨가 화씨에서 섭씨로 바뀌는 데 약간의 어려움이 있습니다.Google 날씨 API가 F에서 C로 변경됩니다.

현재 날씨를 바꿀 때만 작동하지만 Im을 바꿀 때가 아닙니다.

모든 요망?

이것은 내 코드입니다.

<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

toCelsius($current[0]->temp_f['data']가 구글 날씨 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']

그럼 당신이 할 일은 이것이다 :