垂直工作台输出

我有这个 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;

这段代码给出了水平输出的结果。

但我需要它处于垂直位置。

通过简单的改变就可以得到这个结果吗?

婷婷同学_
浏览 150回答 2
2回答

蛊毒传说

如果您想要每行一个数字,则应该通过tr在循环内移动 -pairs 来工作:foreach($row as $column) {&nbsp; &nbsp; $table .="<tr><td>";&nbsp; &nbsp; $values = implode(",",$column);&nbsp; &nbsp; $table .= count($column);&nbsp; &nbsp;&nbsp; &nbsp; $table .="</td></tr>";}注意:不要忘记删除电流$table .= "<tr>";和$table .= "</tr>";线路。如果您只想要一列中的数据,则实际上不需要使用表。您可以只回显 div 中的数字。

缥缈止盈

您可以简单地包含循环<tr>内部foreach:foreach($output as $row) {&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; foreach($row as $column) {&nbsp; &nbsp; &nbsp; &nbsp; $table.="<tr>";&nbsp; &nbsp; &nbsp; &nbsp; $table .="<td>";&nbsp; &nbsp; &nbsp; &nbsp; $values = implode(",",$column);&nbsp; &nbsp; &nbsp; &nbsp; $table .= count($column);&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $table .="</td>";&nbsp; &nbsp; &nbsp; &nbsp; $table.="</tr>";&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; }}&nbsp; &nbsp;&nbsp;$table.="</table>";&nbsp; &nbsp;&nbsp;echo $table;
打开App,查看更多内容
随时随地看视频慕课网APP