List all Images in Folder with PHP

Hello, assuming your folder structure for this process is as follows;

- index.php
- images
    - img1.png
    - img2.png
    - img3.png

your index.php codes

foreach(glob(__DIR__ . '/images/*.{png,jpg,jpeg,gif,webp}', GLOB_BRACE) as $image) {
    echo sprintf('<img src="images/%s" alt="" />', basename($image));
}

 

Comments

There are no comments, make the firs comment