How to make this code more efficient? Huge loop can not be managed by the server
<p>I run a quite long loop and I guess this is very hard for the server to manage. In the <code>$i</code> range the 95% of the images will be wrong paths.</p>

<p>I was wondering what are some ways to lighten this.
For example, to show an image only when there is an image ( and not the not found icon ), or to show for example the results on every 50 loops (i don't know if this will help it).</p>

<p>Thank you!</p>

<pre><code>&lt;?php

for ($i = 3093920; $i &lt;= 3094960; $i++) { ?&gt;

&lt;img src="https://sphotos-a.xx.fbcdn.net/hphotos-snc6/6873_107513793780_&lt;?php echo $i; ?&gt;_s.jpg"&gt;

&lt;?php } ?&gt;
</code></pre>
