Re: ### Image Display Problem ###

From: Date: Tue, 26 Sep 2000 07:51:28 +0000
Subject: Re: ### Image Display Problem ###
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17545@lists.php.net to get a copy of this message
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

« previous php.general (#17545) next »