Saturday, 15 March 2014

php - Check if DOM element attribute is not empty -



php - Check if DOM element attribute is not empty -

i check if attribute exists , if not empty. utilize php simple html dom parser explore dom. tried under attribute filters tab.

as illustration got this:

if ( $html->find('meta[property=og:locale]') && ifnotemptycondition ) { foreach ($html->find('meta[property=og:locale]') $element) { echo $element->content; } } else { echo 'votre site ne propose pas la balise <em>og:locale</em>'; } echo '<br>';

in if don't know how if og:locale attribute not empty.

it's little different angle: skipping empty ones within foreach help of continue:

$elements = $html->find('meta[property=og:locale]'); foreach ($elements $element) { if ($element->content === '') { continue; } echo $element->content; }

php dom

No comments:

Post a Comment