我目前有一个列表(<ul>)我已经分成两列的人。但在完成代码后,我想知道是否有更有效或干净的方法来做同样的事情。使用模数的清洁方式列
echo "<table class='area_list'><tr>";
// Loop users within areas, divided up in 2 columns
$count = count($areaArray);
for($i=0 ; $i<$count ; $i++) {
$uid = $areaArray[$i];
// get the modulus value + ceil for uneven numbers
$rowCalc = ($i+1) % ceil($count/2);
if ($rowCalc == 1) echo "<td><ul>";
// OUTPUT the actual list item
echo "<li>{$users[$uid]->profile_lastname}</li>";
if ($rowCalc == 0 && $i!=0) echo "</ul></td>";
}
echo "</tr></table>";
对不起鸡蛋里挑骨头,但你错过了您的交易tr标签 –
哈哈!一点也不。谢谢:) – JeroenEijkhof