title: How do I test if an remote image file exists in php?
body: <p>This spits out a whole heap of NO's but the images are there and path correct as they are displayed by <code>&lt;img&gt;</code>.</p>
  
  <pre><code>foreach ($imageNames as $imageName) 
  {
      $image = 'http://path/' . $imageName . '.jpg';
      if (file_exists($image)) {
          echo  'YES';
      } else {
          echo 'NO';
      }
      echo '&lt;img src="' . $image . '"&gt;';
  }
  </code></pre>