
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get All 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.
Advertisements