1 回答

TA贡献1779条经验 获得超6个赞
您可以使用类似如下的表。仅举一例:
<?php
$url = ('https://www.yr.no/sted/Norge/Vestland/Bergen/Bergen/varsel.xml');
$feed = simplexml_load_file($url) or die('Can not connect to server');
$result = array();
foreach ($feed->forecast->tabular->time as $content) {
array_push($result, [ "from" => (string)$content['from'],
"to" => (string)$content['to'],
'symbol' => (string)$content->symbol['name'],
'temperature' => (string)$content->temperature['value'],
'windDirection' => (string)$content->windDirection['code'],
'windSpeed' => (string)$content->windSpeed['mps'],
]);
}
?>
<table border=1 cellpadding=5 style=" background:blue; color: #fff;">
<?php foreach ($result as $value) { ?>
<tr><td>Bergen <br /><?php echo $value['from'] ?> to <?php echo $value['to'] ?></td>
<td><?php echo $value['symbol'] ?></td>
<td><?php echo $value['temperature'] ?></td>
<td><?php echo $value['windDirection'] ?></td>
<td><?php echo $value['windSpeed'] ?></td></tr>
<?php } ?>
</table>
- 1 回答
- 0 关注
- 112 浏览
添加回答
举报