title: Descendant selectors in php simple dom
body: <p><a href="http://simplehtmldom.sourceforge.net/manual.htm" rel="nofollow noreferrer">http://simplehtmldom.sourceforge.net/manual.htm</a> </p>
  
  <p>PHP Simple dom descendant selection issue, consider the following html</p>
  
  <pre><code>&lt;ul class="chunklist chunklist_set"&gt;
  
  &lt;li&gt;
  &lt;a href="/test/php/book.calendar.html"&gt;Calendar&lt;/a&gt; 
  
  &lt;ul class="chunklist chunklist_set chunklist_children"&gt;
  
  &lt;li&gt;&lt;a href="/test/php/intro.calendar.html"&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="/test/php/calendar.setup.html"&gt;Installing/Configuring&lt;/a&gt;&lt;/li&gt;
  
  
  &lt;li&gt;
  &lt;a href="/test/php/book.datetime.html"&gt;Date/Time&lt;/a&gt; — Date and Time
  
  &lt;ul class="chunklist chunklist_set chunklist_children"&gt;
  &lt;li&gt;&lt;a href="/test/php/intro.datetime.html"&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="/test/php/datetime.setup.html"&gt;Installing/Configuring&lt;/a&gt;&lt;/li&gt;
  
  
  &lt;li&gt;
  &lt;a href="/test/php/book.hrtime.html"&gt;HRTime&lt;/a&gt; — High resolution timing
  
  &lt;ul class="chunklist chunklist_set chunklist_children"&gt;
  &lt;li&gt;&lt;a href="/test/php/intro.hrtime.html"&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="/test/php/hrtime.setup.html"&gt;Installing/Configuring&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;/li&gt;
  
  &lt;/ul&gt;
  </code></pre>
  
  <p>I am trying to group the selections as per the html code above. Here is where i get stuck im my php: </p>
  
  <pre><code>foreach ($html-&gt;find('ul.chunklist ul.chunklist_set') as $ul) {  // $html accepts mixed classes
  
      $links[] = $ul-&gt;find('li a')-&gt;href;  // now I have the correct array to work with
  
      foreach ($ul-&gt;find('li') as $li) {
  
          //$nulinks[] = $li-&gt;find('a')-&gt;href ;
  
          foreach ($li-&gt;find('a') as $a) {
  
              //$filtlinks[] = $a-&gt;href ;
          }
      }       
  }
  </code></pre>
  
  <p>My $links array spits out:</p>
  
  <pre><code>Array
  (
      [0] =&gt; 
      [1] =&gt; 
      [2] =&gt; 
  )
  </code></pre>
  
  <p>Any ideas guys?</p>
  
  <p>Pretty sure the same selectors would apply to jquery, if that gives anyone a clue how to deal with this bit of tricky html</p>