Jump to content

find all images in a folder starting by "photo_" and display them


gdfhghjdfghgfhf

Recommended Posts

i have a bunch of pics in a folder of my site (called /images/), and on a page i'd like to display all pictures starting with the prefix "photo_"

 

the files i want are all starting by photo_ but have different names, and there is too many to enter them manually

 

how would it be possible to find all pics with that particuliar prefix, and display them?

Thanks a lot! Did exactly what i wanted ;)

 

only one detail: the first image i am getting is blank, it is trying to show image from "images/photo_" nothing more... there isnt even a filename after the prefix....

 

i have 8 images in the folder i am testing, and it is displaying 9... so its not a problem with the files or the filenames

 

weird

Just to make sure

 


foreach($pics as $pic)
if ( file_exists('images/'.$pic) )
	echo '<image src="images/'.$pic.'"><br>\n';

 

Seems redundant though. Try dumping $pics with print_r... might help you get to the bottom of the invalid file issue.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.