A solution with a defensive conditional statement should be added to check the variable html contents are set before calling find().

require_once(‘simple_html_dom.php’);

$suggestions = array();

$htmlw = new simple_html_dom();

$htmlw = file_get_html(‘http://www.thesaurus.com/browse/’.$val);

if($htmlw && is_object($htmlw) && isset($htmlw->nodes)){

$listDiv = $htmlw->find(‘.relevancy-list’, 0);

for ($i = 0; $i <= 5; ++$i) {

$list = $listDiv->find(‘ul’, $i);

}

}

Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.