mat*_*att 6 html php directory
像这样非常简单的文件夹结构......
我想知道使用php读取这个img文件夹并创建一个微观网站,通过"prev"和"next"链接循环遍历这个图像是多么困难.
所以我不想手动指定图像的文件名是什么.我只想在图像文件夹中添加图像,然后运行php脚本并创建类似的导航
<a href="nextimage-link" class="next">Next Image</a>
<a href="previmage-link" class="prev">Previous Image</a>
Run Code Online (Sandbox Code Playgroud)
因此,每当我点击"下一张图片"链接时,它都会更新网站并显示下一张图片.
建造这个很复杂吗?有什么想法吗?提前感谢您的帮助和帮助.
M. *_*far 11
考虑以下情况,我假设img文件夹位于/ var/www文件夹中:
$dir = "/var/www/img/*.jpg";
//get the list of all files with .jpg extension in the directory and safe it in an array named $images
$images = glob( $dir );
//extract only the name of the file without the extension and save in an array named $find
foreach( $images as $image ):
echo "<img src='" . $image . "' />";
endforeach;
Run Code Online (Sandbox Code Playgroud)
为了获得更好的UI,您可以创建一个图像路径数组并将它们存储在JavaScript数组中.然后使用"上一个"和"下一个"按钮更改图像阵列的索引并在单个img标记中显示当前值.
| 归档时间: |
|
| 查看次数: |
18139 次 |
| 最近记录: |