当我创建一个循环来格式化一些像这样的 html 时:
$pieces = Equipment::find_all();
foreach($slots as $slot) {
echo "<h3>".ucfirst($slot)."</h3>";
echo "<table class=\"eq_table\"><th><td>Name</td><td>P.AC</td><td>M.AC</td><td>Saves</td><td>Dex</td><td>Str</td><td>Int</td><td>Wis</td><td>Con</td><td>Hit</td><td>Dam</td><td>Hp</td><td>Mana</td></th>";
foreach($pieces as $piece) {
if($piece->slot == $slot) {
echo "<tr><td>$piece->name</td><td>$piece->p_ac</td><td>$piece->m_ac</td><td>$piece->saves</td><td>$piece->dev</td><td>$piece->dex</td><td>$piece->str</td><td>$piece->intel</td><td>$piece->wis</td><td>$piece->con</td><td>$piece->hit</td><td>$piece->hit</td>$piece->dam</td><td>$piece->hp</td><td>$piece->mana</td></tr>";
}
}
}
我得到这个明显不需要的输出:
页面底部有一个没有标题的额外表格。是什么导致了这种行为,我该如何解决?