Re: [PHP] ### Image Display Problem ### From: David Robley (huntsman <email protected>)
Date: 09/26/00

On Tue, 26 Sep 2000, Theodore Jones wrote:
> Hello All,
>
> Can anyone point me in the right direction in trying to display the
> first
> image, and only the first image within a series of subdirectories, one
> image
> per subdirectory? I can iterate through series of directories, one by
> one,
> but once "in" a directory, I'm at a loss as to how to read just the
> first
> image in the directory, display it, and move on to the next dir...?
>
> Thanks to Lawrence Sheed for an earlier but much too compex (for me to
> decipher and use) large snippet of code. I'll save that until I'm more
> adept
> with PHP in general...
>
>
> ~ Theo

You'll be using opendir and readdir to get the contents of a directory, and
is_dir to check whether to follow down a directory structure. As you loop
through the contents of a directory, test the filename to see if it meets
your definition of image (ie .gif extension or whatever), display the
image, or store it's filename in an array, or whatever, and use break to
drop out of the loop currently reading that directory's contents.

There have been a number of snippets of code published here recently for
tracking through directories and reading the contents, so a skim of the
archives may be rewarding.

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>