Your gonna want to create a loop which counts to 4 and when it hits 4, put in a </tr><tr><td>.$key.</td>
<?php
$file = "widget.csv";
@$fp = fopen($file, "r") or die("Could not open file for reading");
$outputArray = array();
$count = 0;
while(($shop = fgetcsv($fp, 1000, ",")) !== FALSE)
{
$outputArray[array_shift($shop)] = array_filter($shop);
}
print_r($outputArray);
echo "\n<br />";
//display
echo "<table>";
foreach ($outputArray as $alphabetical=>$value){
echo "<th><b>" . $alphabetical ."</b></th>";
echo "<tr>";
foreach ($value as $key){
if ($count == 4){
echo '</tr><tr><td>'.$key.'</td>';
$count = 0;
}Else{
echo "<td>" . $key . "</td>";
}
$count++;
}
echo "</tr>";
$count = 0;
}
echo "</table>";
echo "\n<br />";
?>
That should do what you need but I haven't tested it.