Q:

simpleHTMLdom - Using multiple URLs from an array

In my UI there is a text area that has a list of URLs separated by new line.
I am getting this into a string and exploding it using newline character. I am getting this error:

Fatal error: Call to a member function find() on a non-object in C:\xampp\htdocs\apps\lt\track-them.php on line 34

$myurl       = "http://mydomain.com/testpage1.html";
$str         = "http://www.domain.com/page1.html
http://www.homepage.com/page2.html
http://www.internet.com/index.html";

$backlinkarr = explode("\n", $str);
echo '<table border=1>';
foreach ($backlinkarr as $backlinkitem) {
    $backlinkitem = trim($backlinkitem);
    $LinkCount    = 0;
    $html         = file_get_html($backlinkitem);
    foreach ($html->find('a') as $link) {
        if ($link->href == $myurl) {
            $LinkCount += $LinkCount + 1;
        }
    }
    echo $backlinkitem . ' (' . $linkCount . ')';
}

A:

on windows new line is \r\n
also, your error suggests that $html is not an object, meaning previous line fails. so, debug there with var_dump($backlinkitem) if it is correct and also you can use file_exists to verify if that file actually exists.

