Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get all the images from a folder in php

I am using WordPress. I have an image folder like mytheme/images/myimages.

I want to retrieve all the images name from the folder myimages

Please advice me, how can I get images name.

like image 451
Sksudip Avatar asked Jun 15 '13 09:06

Sksudip


People also ask

How to get all images from a folder in php?

Show activity on this post. $dir = "mytheme/images/myimages"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } $images=preg_grep ('/\. jpg$/i', $files);

How do I display all images in a directory in HTML?

Simply run the command from a command line window in the directory where your images are stored. If you need to have the all. html in some other place either move it there or change to >> C:\files\html\all.


1 Answers

try this

$directory = "mytheme/images/myimages"; $images = glob($directory . "/*.jpg");  foreach($images as $image) {   echo $image; } 
like image 144
sharif2008 Avatar answered Sep 21 '22 07:09

sharif2008