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
很高兴帮助你:) –