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


$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);



Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.