how to fix or optimize code to ignore memory size error in PHP
<p>I wrote a image crawler with simple_html_dom library,
I used this code to fetch all images in a web site ;</p>

<pre><code>include 'simple_html_dom.php';
$img_array = array();
if (isset($_POST['url'])) {
    $url = $_POST['url'];
    $html = file_get_html($url);
    echo $html-&gt;getElementByTagName('title')-&gt;innertext();
    foreach ($html-&gt;find('a') as $a) {

        if (strpos($a-&gt;href, $url) !== FALSE) // only images from this site
        {
            //
            //    find_images($a-&gt;href);
            $imgs = file_get_html($a-&gt;href);
            foreach ($imgs-&gt;find('img') as $img) {
                if(!in_array($img-&gt;src, $img_array))
                {
                    echo '&lt;img src="' .$img-&gt;src. '" class="thumb"&gt;';
                    $img_array[] = $img-&gt;src;
                }
            }
            echo '&lt;hr&gt;';
        }
    }
}
</code></pre>

<p>but whene i execute this code i get <code>Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 71 bytes) in /home/iphotosh/public_html/test/simple_html_dom.php on line 122</code></p>

<p>test and demo : <a href="http://test.iphotoshop.ir/" rel="nofollow">test.iphotoshop.ir</a></p>

<p>how to fix this error or how to opti,ize this code for fetch all images from a web site?</p>
