RE: [PHP] ### Image Display Problem ### From: Lawrence.Sheed <email protected>
Date: 09/26/00

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 <email protected>]
Sent: September 26, 2000 03:50 PM
To: php-general <email protected>
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 <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>

-- 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>