如何使用php调用文件夹中的图像以在幻灯片中使用


How would I call images from a folder to use in my slideshow using php

我无法找到我的具体问题的答案。

我已经有幻灯片了,我不需要创建一个。我知道我需要创建一个数组,并为每个循环运行a来获取幻灯片中的图像。

我需要知道的是如何使用文件夹的内容创建数组,在本例中是图像。我到处都找不到明确的答案。

使用glob函数:

<?php
foreach(glob('*.jpg') as $image) {
    echo $image; // will print file name;
}