RE: [PHP] ### Image Display Problem ###

From: Date: Tue, 26 Sep 2000 07:59:23 +0000
Subject: RE: [PHP] ### Image Display Problem ###
Groups: php.general 
Request: Send a blank email to php-general+get-17547@lists.php.net to get a copy of this message
I would build an array of directories first. Then iterate through your array passing each directory to this: function Print_First_Image($sPath) { if(!$sPath) { $sPath = "."; } $dir_handle = opendir($sPath); //Read Directory while($file = readdir($dir_handle) && !($out)) { //Is it a picture file? if((preg_match('/jpg/i',$file)) || (preg_match('/png/i',$file)) || (preg_match('/gif/i',$file)) || (preg_match('/jpeg/i',$file))) { return ("<img src='$sPath/$file'>"); } } } Use it something like this for ($count =0;$count < sizeof ($dirarray) ; $count ++ ) { $outputstring = Print_First_Image ($dirarray[$count]); print $outputstring; } If you need help in making an array of directories... I'll write one, but this should give you an idea of how to go about it. Cheers, Lawrence. -----Original Message----- From: Theodore Jones [mailto:theoj@transport.com] Sent: September 26, 2000 03:50 PM To: php-general@lists.php.net Subject: [PHP] ### Image Display Problem ### 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#17547) next »