如何修改此xml数据以列表格式显示?
foreach ($dataArray['simpleforecast']['forecastday'] as $arr) {
$html .= "<td align='center'>" . $arr['date']['weekday'] . "<br />";
$html .= "<img src='http://icons-pe.wxug.com/i/c/a/" . $arr['icon'] . ".gif' border=0 /><br />";
$html .= "<font color='red'>" . $arr['high'][$tempScale] . $tempUnit . " </font>";
$html .= "<font color='blue'>" . $arr['low'][$tempScale] . $tempUnit . "</font>";
$html .= "</td>";
}
答案 0 :(得分:0)
我只是假设你的意思是这个,因为你并不是很清楚描述你想要的东西。
$html = "<ul>";
foreach ($dataArray['simpleforecast']['forecastday'] as $arr) {
$html .= "<li>" . $arr['date']['weekday'] . "<br />";
$html .= "<img src='http://icons-pe.wxug.com/i/c/a/" . $arr['icon'] . ".gif' border=0 /><br />";
$html .= "<font color='red'>" . $arr['high'][$tempScale] . $tempUnit . " </font>";
$html .= "<font color='blue'>" . $arr['low'][$tempScale] . $tempUnit . "</font>";
$html .= "</li>";
}
$html .= "</ul>";
要跳过当天,您可以在第三行使用以下伪代码
if(today) continue;
但是因为我现在不想检查是否到了白天,所以我把它打开了让你弄明白。