[ACCEPTED]-How to check if a SimpleHTMLDom element does not exist-simple-html-dom

Accepted answer
Score: 11
if(($html->find('.description', 0))) {
    echo 'set';
}else{
    echo 'not set';
}

http://www.php.net/manual/en/control-structures.if.php

0

Score: 1

According to the SimpleHtmlDOM Api str_get_html($html) expects 2 a string as input. First check with a html 1 validator if your code is well formatted.

$htmlObj = str_get_html($html);
if (!is_object($htmlObj)) return; // catch errors 

// or wrap further code in 
if (is_object($htmlObj)) { /* doWork */ }
Score: 0
$avalable = ($element->find('span.sold-out-text', 0)) ? 1 : 0;

It works for me.

0

More Related questions