我有这个 php 代码:foreach($output as $row) { $table.="<tr>"; foreach($row as $column) { $table .="<td>"; $values = implode(",",$column); $table .= count($column); $table .="</td>"; } $table.="</tr>"; } $table.="</table>"; echo $table;这段代码给出了水平输出的结果。但我需要它处于垂直位置。通过简单的改变就可以得到这个结果吗?
2 回答
蛊毒传说
TA贡献1895条经验 获得超3个赞
如果您想要每行一个数字,则应该通过tr在循环内移动 -pairs 来工作:
foreach($row as $column) {
$table .="<tr><td>";
$values = implode(",",$column);
$table .= count($column);
$table .="</td></tr>";
}
注意:不要忘记删除电流$table .= "<tr>";和$table .= "</tr>";线路。
如果您只想要一列中的数据,则实际上不需要使用表。您可以只回显 div 中的数字。
缥缈止盈
TA贡献2041条经验 获得超4个赞
您可以简单地包含循环<tr>内部foreach:
foreach($output as $row) {
foreach($row as $column) {
$table.="<tr>";
$table .="<td>";
$values = implode(",",$column);
$table .= count($column);
$table .="</td>";
$table.="</tr>";
}
}
$table.="</table>";
echo $table;
- 2 回答
- 0 关注
- 65 浏览
添加回答
举报
0/150
提交
取消