I'm trying to take an array and turn it into an html table where the number of columns can be altered. Each number appears in a seperate cell. The code I have reached is:
But instead of it looking like:PHP Code:$input = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten');
$cols = 5;
echo "<table border=\"5\" cellpadding=\"10\">";
for ($i=0; $i < count($input); $i++)
{
echo "<tr>";
for ($c=0; $c<$cols; $c++)
{
echo "<td>$input[$i]</td>";
}
echo "</tr>";
}
echo "</table>";
It looks like:Quote:
one two three four five
six seven eight nine ten
Where am I going wrong?Quote:
one one one one one
two two two two two
three three three three three
four four four four four
five five five five five
six six six six six
seven seven seven seven seven
eight eight eight eight eight
nine nine nine nine nine
ten ten ten ten ten
