Get all images from folder in PHP

WBOY
Release: 2023-08-28 06:00:02
forward
1285 people have browsed it

Get all images from folder in PHP

glob function can be used to get images from a specific folder. Below is the sample code for the same -

Specify the path to the images folder and extract all the files with .png extension. They are displayed with the help of foreach loop -

$dir_name = "path/to/image/folder/";
$images = glob($dir_name."*.png");
foreach($images as $image) {
   echo &#39;<img  src="&#39;.$image.&#39;" / alt="Get all images from folder in PHP" ><br />&#39;;
}
Copy after login

Based on the folder containing all the images, returns the path of each image present in that folder.

The above is the detailed content of Get all images from folder in PHP. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!