Collecting all pictures in folder to display [solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

Collecting all pictures in folder to display [solved]

Post by the9ulaire »

So I have a folder with multiple pictures in it. How can I use php to display each picture in the folder?
Last edited by the9ulaire on Wed Mar 19, 2008 1:01 pm, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Collecting all pictures in folder to display

Post by Christopher »

(#10850)
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Collecting all pictures in folder to display

Post by Zoxive »

Code: Select all

$Pictures = glob('/path/to/pictures/*.jpg');
foreach($Pictures as $Pic){
  echo 'The Picture name is ' . $Pic . '<br/>';
}
Simple example.
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

Re: Collecting all pictures in folder to display

Post by the9ulaire »

Zoxive wrote:

Code: Select all

$Pictures = glob('/path/to/pictures/*.jpg');
foreach($Pictures as $Pic){
  echo 'The Picture name is ' . $Pic . '<br/>';
}
Simple example.
Awesome! Thank you so much!
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Collecting all pictures in folder to display

Post by Zoxive »

the9ulaire wrote:Awesome! Thank you so much!
Just a FYI, glob has alot more overhead then say opendir();

http://www.code2design.com/forums/glob_vs_opendir

http://cboard.cprogramming.com/showthread.php?t=76987
Post Reply