I have this html:
<h2><a href="http://.... > title</h2>
How can I get the string “href”?
I tried with:
include('simple_html_dom.php');
$html = file_get_html('http://...');
foreach($html->find('h2')->find('a') as $k) {
echo $k->href . '<br>';
}
error: Call to a member function find() on a non-object
I have not used PHP Simple HTML DOM Parser…but I think the error could be because it returns you a string and you are applying the find function on that returned string which is expecting a html object to be passed…
The previous solution is wrong bcz it just searched for a string while find function searches a tag..
One possible way is what I have commented..
remove first ‘h2’ find creteria and apply for all ‘a’ that is
Other possible solution is use php inbuild file_get_contents and seach by regular
expressions…I have done that for you…