title: PHP Parsing with simple_html_dom, please check
body: <p>I made a simple parser for saving all images per page with simple html dom and get image class but i had to make a loop inside the loop in order to pass page by page and i think something is just not optimized in my code as it is very slow and always timeouts or memory exceeds. Could someone just have a quick look at the code and maybe you see something really stupid that i made? </p>
  
  <p>Here is the code without libraries included...</p>
  
  <pre><code>$pageNumbers = array(); //Array to hold number of pages to parse
  
  $url = 'http://sitename/category/'; //target url
  $html = file_get_html($url);
  
  
  //Simply detecting the paginator class and pushing into an array to find out how many pages to parse placing it into an array
  foreach($html-&gt;find('td.nav .str') as $pn){
      array_push($pageNumbers, $pn-&gt;innertext);               
  }
  
  // initializing the get image class
  $image = new GetImage;
  $image-&gt;save_to = $pfolder.'/'; // save to folder, value from post request.
  
  //Start reading pages array and parsing all images per page.
  foreach($pageNumbers as $ppp){
  
      $target_url = 'http://sitename.com/category/'.$ppp; //Here i construct a page from an array to parse.
      $target_html = file_get_html($target_url); //Reading the page html to find all images inside next.
  
      //Final loop to find and save each image per page.
      foreach($target_html-&gt;find('img.clipart') as $element) {
          $image-&gt;source = url_to_absolute($target_url, $element-&gt;src);
          $get = $image-&gt;download('curl'); // using GD
          echo 'saved'.url_to_absolute($target_url, $element-&gt;src).'&lt;br /&gt;';           
      }
  
  }
  </code></pre>
  
  <p>Thank you.</p>