javascript inside php error ReferenceError: img is not defined
<p>photos[] is an array of photos names then,</p>

<pre><code>foreach($photos as $key=&gt;$value)
{
    @$blocks .= '&lt;div&gt;&lt;img src="'.$value.'" onload="img=this"&gt;&lt;img src="remove.png" onclick=remove_image(img)&gt;&lt;/div&gt;';
}
</code></pre>

<p>so when clicking on the remove icon for the first photo it works just fine, but the others shows this error:</p>

<p><code>ReferenceError: img is not defined</code></p>
