Cleaner/more effective way to use modulus and creating columned lists
- by WmasterJ
I currently have a list (<ul>) of people that I have divided up into two columns. But after finishing the code for it I keept wondering if there is a more effective or clean way to do the same thing.
echo "<table class='area_list'><tr>";
// Loop users within areas, divided up in 2 columns
$count = count($areaArray);
for($i=0 ; $i<$count ; $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 "</table>";
Any ideas of how to make this cleaner or do it in another way?