Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将数组转换为列表格式_Php_Html_Xml - Fatal编程技术网

Php 将数组转换为列表格式

Php 将数组转换为列表格式,php,html,xml,Php,Html,Xml,如何修改此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'

如何修改此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>";
}
foreach($dataArray['simpleforecast']['forecastday']作为$arr){
$html.=''.$arr['date']['weekday'].“
”; $html.=“
”; $html.=''.$arr['high'][$tempScale].$tempUnit.“; $html.=''.$arr['low'][$tempScale].$tempUnit.“; $html.=”; }
我只是假设你是这个意思,因为你不太清楚自己想要什么

$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>";

但是,由于我现在不知道是否是今天,所以我将此问题留给您解决。

数据还显示了包括当天在内的6天预测。。。如何将其修改为不显示当前日期。感谢您以列表格式而不是水平排列外部数据,但M_rk通过将标记更改为
  • 帮助我解决了这一问题。现在我需要了解如何使其不显示当前日期信息,而是跳过它,只显示其余信息。。。例如,如果今天是星期一。我只想让它给我看周二周三周四等等。谢谢你,我完全忽略了它是表格格式的。。。它现在显示在一个列表中,谢谢。然而,我不能让它不显示今天的信息。。。我试过你提到的if语句,但似乎不起作用。你知道为什么吗?或者它也需要使用“date”(日期),天气数据是从外部来源解析出来的。$arr['date']获取当前日期信息,['weekday']显示周预测。。。。我只是希望它不显示或隐藏当前日期。或者,如果不可能,我可以将其设置为用“今天”一词替换当前日期吗?正如我所说,如果(今天)继续,则行
    只是一个伪代码,旨在说明这个想法。
    if(today) continue;