I can't for the life of me figure out how to put my results into columns. I want the data to look like this:
1 2 3 4
5 6 7 8
So, columns of four and spanning in order left to right. Right now my code just spans vertically in one column.
My code:
<table border="0" cellspacing="0" cellpadding="0">
<?php
function dirImages($dir) {
$d = dir($dir); //Open Directory
while (false!== ($file = $d->read())) //Reads Directory
{
$extension = substr($file, strrpos($file, '.')); // Gets the File Extension
if($extension == ".jpg" || $extension == ".gif" |$extension == ".png") // Extensions Allowed
$images[$file] = substr($file, 0, -7); // Store in Array
}
$d->close(); // Close Directory
asort($images); // Sorts the Array
return $images;
}
$array = dirImages('images/sm/'); // Image folder
foreach ($array as $key => $image) // Display images
{
echo '<tr><td align="center">';
echo '<img src="images/sm/'.$image.'-sm.jpg" width="200" height="133" border="0" alt=""><br />';
echo '<a href="">Larger</a> | <a href="">Full Size</a><br /><br />';
echo '</td></tr>';
}
?>
</table>