<?php
$fienames = glob('/img/*.png');
foreach ($filenames as $filename) {
echo "<div-->$filename
";
}
?>
$fienames !== $filenames
<?php
$dir = 'images/';
$cols = 3;
$files = scandir($dir);
echo "<table-->";
$k = 0;
for ($i = 0; $i < count($files); $i++) {
if (($files[$i] != ".") && ($files[$i] != "..")) {
if ($k % $cols == 0) echo "";
echo "";
$path = $dir.$files[$i];
echo "<a href="$path">";
echo "<img src="$path" alt width="100">";
echo "</a>";
echo "";
if ((($k + 1) % $cols == 0) || (($i + 1) == count($files))) echo "";
$k++;
}
}
echo "";
?>
the <div>img.png</div>
the <div>img.png</div>
the <div>img.png</div>
the <div>img.png</div>
commented on June 10th 19 at 14:29<?php
$dir = 'img/';
$cols = 3;
$files = scandir($dir);
$k = 0;
for ($i = 0; $i < count($files); $i++) {
if (($files[$i] != ".") && ($files[$i] != "..")) {
echo "<div-->";
$path = $dir.$files[$i];
echo "<a href="$path">";
echo "<img src="$path" alt width="100">";
echo "</a>";
echo "";
}
}
?>
Find more questions by tags PHP
/?>
- Baylee_Kulas commented on June 10th 19 at 14:30