I have to make a table with an amount of columns that can be set by a variable ($cols) with each cell containing a picture obtained through a GLOB Array. The code I have now will output a table with the correct amount of cells and columns but I need help getting each picture to show up.
<?php
$cols = 4;
$array = glob("include/*.{jpg}", GLOB_BRACE);
$output = "<table>
";
$cell_count = 1;
for ($i = 0; $i < count($array); $i++) {
if ($cell_count == 1) {
$output .= "<tr>
";
}
$output .= "<td><img src=$array></td>
";
$cell_count++;
if ($cell_count > $cols || $i == (count($array) - 1)) {
$output .= "</tr>
";
$cell_count = 1;
}
}
$output .= "</table>
";
echo "$output";
?>