Get all the images from a folder in PHP
The glob function can be used to get the images from a specific folder. Below is a sample code for the same −
The path to the image folder is specified and all the files that have a .png extension are extracted. They are displayed with the help of the foreach loop −
$dir_name = "path/to/image/folder/";
$images = glob($dir_name."*.png");
foreach($images as $image) {
echo '<img src="'.$image.'" /><br />';
}
Based on the folder that contains all images, the path of every image present inside the folder is returned.
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP