0

I'm getting html from different pages ($linkHtml) and want to get elements from those pages. With this I get Fatal error: Call to a member function find() on a non-object. If I move the second foreach out I get the result that I want from one page. How should I do to get the elements from all pages?

$url = 'http://page/';

foreach ($dataArray as $link) {
        $linkHtml = file_get_html($url . $link);

        foreach ($linkHtml->find('text') as $text) {

        }
}
e.e
  • 85
  • 2
  • 5
  • I'm guessing that `file_get_html` is failing and returning a NULL, and that you need to check that it succeeds and you're getting back a proper object. – Andy Lester Nov 25 '12 at 18:05

1 Answers1

0

I could't find any documentation on file_get_html() on php.net!? I would use

$doc = new DOMDocument();
$doc->loadHTML(file_get_contents($url . $link)));

file-get-contents

domdocument.loadhtml

aichingm
  • 738
  • 2
  • 7
  • 15