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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.