3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $foo = "<p class='xdescriptionx'><a data-ct='campaign_softlayer_inarticle_ad' target='_blank' href='someurl'><img class='lazy-img description' src='someurl' data-original='someurl' /></a></p>"; $dom = new DomDocument(); $dom->loadHtml($foo); $finder = new DomXPath($dom); $classname="description"; $nodes = $finder->query("//p[contains(@class, '$classname')]"); var_dump($nodes->length);
based on WVorA
Output for 5.6.0 - 7.2.0
int(1)