PHP file_get_contents does not really determine if file is present
<p>I'm trying to use file_get_contents to test if a .jpg exists in a directory and if so display it else just stop the loop.</p>

<p>This appears to work great EXCEPT when the .jpg is not in the directory it continues to look and display missing thumbnails up to 10 images.</p>

<p>Is there something else besides file_get_contents?  I've tried to use absolute path as well with the same results.</p>

<pre><code>&lt;?
$image = "&lt;br&gt;";
$ListingRid = $row['MLS_NUMBER'];
$img_cnt = 1;
for ($c=1;$c&lt;11;$c++) {
    if ($c&lt;10)
        $c_ext = "".$c;
    else
        $c_ext = $c;

    if (file_get_contents("http://mydomain.com/images/{$ListingRid}_{$c_ext}.jpg"))
        $image .= "&lt;img src=http://mydomain.com/images/{$ListingRid}_{$c_ext}.jpg alt='' width='100' height='75' border='0' /&gt;";
    else
        $c=12;

    $img_cnt++;
    if ($img_cnt == 3) {
        $image .= "&lt;br&gt;";
        $img_cnt = 0;
    }

}

?&gt;
</code></pre>
