【发布时间】:2013-09-11 13:06:32
【问题描述】:
我目前已使用 php 将我目录中的文件夹中的图像显示到屏幕上,如下所示:
$file_display = array('jpg', 'jpeg', 'png', 'gif');
$dir = 'images';
if (file_exists($dir) == false)
{
echo 'Doesnt exist';
}
else
{
$dir_contents = scandir($dir);
foreach ($dir_contents as $file)
{
$file_type = strtolower (end (explode('.', $file)));
if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true)
{
echo '<img src="', $dir, '/', $file, '" alt="', $file,'" />';
}
}
}
我为屏幕尺寸设置了 600 像素的宽度。我现在尝试将这些图像显示在屏幕下方的 4 列中,并要求所有图像大小相同。
有人对如何做到这一点有任何想法吗?
【问题讨论】: