Got it to work using the following code
thanks for the help
$maxItemsPerRow = "4";
$pets = array('dog','cat','mouse','snake','hamster','pig','cow');
$numberItemsInArray = count($pets);
print "<table width=\"300\" cellpadding=\"0\" cellspacing=\"0\">";
$count = 0;
print "<tr>";
for ($i = 0...