You use modulus and some switching logic. There are several different ways to get there, here is one:
PHP Code:
$iNumPerRow = 3;
if (count($aFiles) > 0)
{
print('<table border="1">');
print('<tr>');
for ($i = 0; $value = current($aFiles); next($aFiles), ++$i)
{
$key = key($aFiles);
if ($i > 0 && ($i % $iNumPerRow == 0))
{
print('</tr><tr>');
}
printf('<td>%s - %s.<a href="savedImage/%s" target="blank"><img src="savedImages/%s" width="300"/></a></td>',
$key, date('F d Y', $value), $key, $key);
}
print('</tr>');
print('</table>');
}