Re: Showing pics if file exists
| From: | Philip Olson | Date: | Sun, 15 Oct 2000 03:10:41 +0000 |
| Subject: | Re: Showing pics if file exists | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20197@lists.php.net to get a copy of this message | ||
If you want to check for images in a directory and list them all then try
this. Perhaps you can play with this and create some goodness. It
basically puts all images (via extension def) into an array, named $files.
<snip>
$dir = "images/";
function Get_Image_list($dir) {
if(!$dir) {
$dir = ".";
}
$file_array = array();
$dir_handle = opendir($dir);
$a = 0;
while($file = readdir($dir_handle)) {
if((preg_match('/jpg/',$file)) ||
(preg_match('/png/',$file)) ||
(preg_match('/gif/',$file)) ||
(preg_match('/jpeg/',$file))) {
$file_array[$a] = $file;
$a++;
}
}
return $file_array;
}
// not let's create your array
$files = Get_Image_list($dir);
</snip>
if your file is in this array then it exists :) good luck!
philip olson
--
be outside the box.
On Sat, 14 Oct 2000, John Paige wrote:
> Trying to show a picture if the file exists.
> Else skip it.
> What should be changed?
>
> <?php
> if("pics/$picname.jpg"){
>
> echo "<B>The picture goes here:</B><BR><IMG SRC= pics/";
> echo "$picname.jpg ";
> }
> ?>
> Thanks,
> JWP
>
>
> --
> 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
>