Note that there are some explanatory texts on larger screens.

plurals
  1. POsimplehtmldom get href of a title
    text
    copied!<p>I have a code below which is working correctly but is missing one thing. It is not returning the value for the <code>$item['link']</code> which is the <code>href</code> of the title.</p> <pre><code>include('simple_html_dom.php'); $html = file_get_html('http://news.google.com/news/section?pz=1&amp;cf=all&amp;ned=us&amp;q=newzealand'); foreach($html-&gt;find('.blended-wrapper') as $article) { $item['title'] = $article-&gt;find('span.titletext', 0)-&gt;plaintext; $item['source'] = $article-&gt;find('span.esc-lead-article-source', 0)-&gt;plaintext; $item['clip'] = $article-&gt;find('div.esc-lead-snippet-wrapper', 0)-&gt;plaintext; $item['link'] = $article-&gt;find('.esc-lead-article-title a')-&gt;href; $articles[] = $item; } echo "&lt;pre&gt;"; print_r($articles); echo "&lt;pre/&gt;"; </code></pre> <p>This is what it outputs, as you see the link key is empty. I've tried so many things. Array</p> <pre><code>( [0] =&gt; Array ( [title] =&gt; New Zealand dominate 2011 after 24 years of pain [source] =&gt; Times of India [clip] =&gt; WELLINGTON: After 24 years of stumbles, disappointments and plain old chokes, New Zealand finally lived up to their billing as world rugby's premier side in 2011. [link] =&gt; ) [1] =&gt; Array ( [title] =&gt; PRESS DIGEST-New Zealand newspapers - Dec 29 [source] =&gt; Reuters [clip] =&gt; WELLINGTON Dec 29 (Reuters) - Following are some of the lead stories from New Zealand metropolitan newspapers on Thursday. Stories may be taken from either the paper or Internet editions of the papers. [link] =&gt; ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload