[thelist] php array looping and GetImageSize

john corry john at neoncowboy.com
Thu Feb 21 01:34:01 CST 2002


I have an array, whihc is created like this

...in a loop
	$images[] .= $img;

Then, I need to loop through the array and perform the following steps:
1) prepend "images/" to each element, so I have a complete path to the image
that $img represents
2) determine it's type and the last 3 letters of the filename before the .
3) based on it's filename and extension, assign it to a variable which will
be plugged into the output

OK, I know how to do all this stuff...but this code doesn't work right and I
can't see why!?

$count = count($images);
						for ($i ; $i < $count ; $i++)
							{
							echo "\n" . $images[$i] . "<br>";
							$pic = $base . $images[$i];
							$type = GetImageSize($pic);
							$type = $type[2];

								// if it's type is .gif (1) and
								if ($type == 1)	// image is a gif, it's the floorplan
									{
										// and if it's small?
										if ( (substr($pic, -6) == "sm.gif") or (substr($pic, -7)
=="sml.gif"))
											{
											//$floor_thumb = $images[$i];
											$floor_thumb = $pic;
												$size = getimagesize($pic);
											$floor_thumb = "<img src=\"$pic\" $size border=\"1\">";
											echo $floor_thumb . " is a gif <br>";
											}

									}
								}

I get a :
Warning: getimagesize: Unable to open 'images/' for reading. in C:\Documents
and
Settings\Administrator\Desktop\aaa_work\mauivacation.info\site\hs~detail2.ph
p on line 76
error!

Why? When I just echo the $images array elements, there are'nt any blank
spaces or elements with no values (and thats the only situation I can see
happening that would result in '$images/' being one of the elements passed
to getimagesize.

any clues?

thanks,
jpc




More information about the thelist mailing list