0
我有這個腳本從API獲取天氣數據。 但我需要每天在單獨的字符串中的溫度。 $ day1Max,$ day1Min,$ day2Max,$ day2Min等...從foreach循環創建多個變量
是否可以從foreach循環獲取這些變量?
<?php
$conditions_week = $forecast->getForecastWeek($latitude, $longitude);
echo "Forecast this week:\n";
foreach($conditions_week as $conditions) {
?>
<tr>
<th><?php echo $conditions->getTime('Y-m-d') . ': ' . $conditions->getMaxTemperature() . "\n"; ?></th>
<th><?php echo $conditions->getTime('Y-m-d') . ': ' . $conditions->getMinTemperature() . "\n"; ?></th>
</tr>
<?php
}
?>
這是輸出:
你,不是所有的英雄穿着斗篷的證明! 謝謝先生,這個作品完美! – Laurenz
很高興幫助你:) –