Page 1 of 1

Collecting all pictures in folder to display [solved]

Posted: Wed Mar 19, 2008 11:29 am
by the9ulaire
So I have a folder with multiple pictures in it. How can I use php to display each picture in the folder?

Re: Collecting all pictures in folder to display

Posted: Wed Mar 19, 2008 11:54 am
by Christopher

Re: Collecting all pictures in folder to display

Posted: Wed Mar 19, 2008 11:54 am
by Zoxive

Code: Select all

$Pictures = glob('/path/to/pictures/*.jpg');
foreach($Pictures as $Pic){
  echo 'The Picture name is ' . $Pic . '<br/>';
}
Simple example.

Re: Collecting all pictures in folder to display

Posted: Wed Mar 19, 2008 1:01 pm
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!

Re: Collecting all pictures in folder to display

Posted: Wed Mar 19, 2008 1:24 pm
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