title: Finding and Printing all Links within a DIV
body: <p>I am trying to find all links in a div and then printing those links.</p>
  
  <p>I am using the Simple HTML Dom to parse the HTML file. Here is what I have so far, please read the inline comments and let me know where I am going wrong.</p>
  
  <pre><code>include('simple_html_dom.php');  
  
  $html = file_get_html('tester.html');
  
  $articles = array();
  
  //find the div the div with the id abcde
  foreach($html-&gt;find('#abcde') as $article) {
  
      //find all a tags that have a href in the div abcde
      foreach($article-&gt;find('a[href]') as $link){
  
          //if the href contains singer then echo this link
          if(strstr($link, 'singer')){
  
              echo $link;
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>What currently happens is that the above takes a long time to load (never got it to finish). I printed what it was doing in each loop since it was too long to wait and I find that its going through things I don't need it to! This suggests my code is wrong.</p>
  
  <p>The HTML is basically something like this:</p>
  
  <pre><code>&lt;div id="abcde"&gt;
  &lt;!-- lots of html elements --&gt;
  &lt;!-- lots of a tags --&gt;
  &lt;a href="singer/tom" /&gt;
  &lt;img src="image..jpg" /&gt;
  &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks all for any help</p>