2 回答
TA贡献1911条经验 获得超7个赞
前提是用户数量相同。
您可以将$usersMON~$usersFRI放入数组中。
array_push($allUsers, $usersMON, usersTUE, usersWED, usersTHU, usersFRI);
然后,显示每个学生的姓名
<?php for ($i=0; $i < $userQuantity; $i++) { ?>
<tr>
<?php foreach ($allUsers as $users) { ?>
<td><?=$users[$i];?></td>
<?php } ?>
</tr>
<?php } ?>
TA贡献1829条经验 获得超7个赞
$users = [
$usersTUE,
$usersWED,
$usersTHU,
$usersFRI
];
$col_count = count($users);
$row_count = 0;
foreach ($users as $u) {
$row_count = max($row_count, count($u));
}
echo "<table>";
for ($i=0; $i<$row_count; $i++) {
echo "<tr>";
for ($t=0; $t<$col_count; $t++) {
$user = $users[$t][$i] ?? [];
echo "<td class='text-center maiuscolo'>" . $user['name'] . "</td>";
}
echo "</tr>";
}
echo "</table>";
- 2 回答
- 0 关注
- 94 浏览
添加回答
举报