I have images in an array and I want them to be display in a table with 3 columns!
So obviously in HTML, it is like:
<table>
<tr>
<td><img src="image1.jpg"></td>
<td><img src="image2.jpg"></td>
<td><img src="image3.jpg"></td>
</tr>
<!-- and so on... -->
</table>
So I want it to print out in PHP but the problem is the code.
My code is like this:
$photos = array( "image1",
"image2",
"image3",
"image4",
"image5",
);
foreach ($photos as $photo) {
$i = 0;
if ($i < 3) {
echo '<td><center><img src="'.$photo.'.jpg"></td>';
$i++;
} elseif ($i == 3) {
echo '</tr><tr>';
$i = 0;
}
}
I don’t know what seems to be the problem and every time I echo out the variable $i, it echoes out like 11111111111111111111111111111111111111111111.
change this
to