【发布时间】:2018-04-26 07:56:53
【问题描述】:
如何在 foreach 函数内的 tablerow 中显示数据?议程变量工作正常,行变量是问题所在,我需要在标签内使用它
<?php
$agenda = $days = json_decode(get_field( "field_uc_content_json" ));
unset($agenda[0]); ?>
<table class="table">
<thead>
<tr>
<th> Day </th>
<th>Description</th>
<th>Hours</th>
</tr>
</thead>
<tbody>
<?php foreach($agenda as $column) { ?>
<tr>
<td><?php echo $column[0]; ?></td>
<td><?php
$rows = explode( "\n", $column[1]);
foreach ($rows as $row) { ?>
<tr> <?php echo $row; ?> </tr>
<?php } ?>
</td>
</tbody>
</table>
第二个foreach
vardump议程
vardump 行
【问题讨论】:
-
你能
var_dump($agenda);和var_dump($rows);吗?我想知道这些数组里面有什么。所以我可以帮助你显示这些值。你的<tbody>的整个代码也会很好。 -
@RonnieOosting 当然,我刚刚编辑了我的问题
-
您也可以编辑
<tbody>代码吗? -
@RonnieOosting 如何>?
-
@RonnieOosting 干杯 m8。希望 OP 仍然阅读此内容并将其中一个答案标记为已接受。 +1 来自我 :)
标签: php foreach html-table