我有這個 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 關注
- 110 瀏覽
添加回答
舉報
0/150
提交
取消