<?php
$array = array('a', 'b', 'c', 'd', 'p');
//instantiate a holding variable to avoid E_NOTICE
$thumbsOutput = array();
$imageFiles = array();
foreach ($array as $i){
$file = "photos/{$i}BRANCH_{$record['PropertyID']}.jpg";
//if the file exists then add it to the thumbnails. otherwise don't
if (file_exists($file)){
$imageFiles[$i] = $file;
$thumbsOutput[$i] <<<HTML
<a href="pop_up101.php?propID={$record["PropertyID"]}&image={$file}">
<img src="{$file}" border="0" height="70" width="70" alt="Property photo" />
</a>
HTML;
} else {
if ($i == 'c' && isset ($imageFiles['b'])) unset ($thumbsOutput['b']);
if ($i == 'c' && isset ($imageFiles['c'])) unset ($thumbsOutput['c']);
}
}
//sort out main output
//perform a double check against spoofed image requests
$file = isset($_GET['image']) ? (in_array($_GET['image'], $imageFile) ? $_GET['image'] : $imageFile['p'] ) : $imageFile['p'];
$mainOutput = <<<HTML
<img src="$file" border="0" height="287" width="416" alt="Property photo" />
HTML;
//display
$_thumbsOutput = implode ("\r\n", $thumbsOutput);
echo <<<HTML
<tr>
<td height="277" width="600">
<div align="center">
$mainOutput
$_thumbsOutput
</div>
</td>
HTML;
?>