【发布时间】:2017-09-10 05:49:51
【问题描述】:
<table style="width: 600px" class="slicedTable">
<tr>
<th>Spetsialist</th>
<th>Tunnid</th>
</tr>
<tr>
<?php foreach($specs as $specName => $spec): ?>
<td><?php echo $specName?>
<tr>
<?php endforeach; ?>
<td>
<?php foreach($tunnid as $tund): ?>
<td><?php echo $tund?></td>
</td>
<?php endforeach; ?>
</tr>
</table>
我需要这个来打印出一个普通的表格,如下所示:
名称 1 - 值 1
name2 - value2
规格:
$specs = array();
foreach($data as $row) {
$workerName = $row['Worker']['name'];
if (!isset($specs[$workerName])) {
$specs[$workerName] = array('procs' => array(), 'extras' => array());
}
但是我似乎无法做到这一点,请帮助。
【问题讨论】:
-
$spec是“名称”,$tund是“值”吗? -
为什么要关桌3次?
-
是的,完全一样
-
不小心把它丢了,我绝望地试了两张相邻的桌子。
-
你的阵列是什么样子的?
标签: php foreach html-table nested