Closed neverender24 closed 6 years ago
I would go the other way:
$h2 = $doc->find('h2');
$desc = $doc->find('.pnlDescription');
$address = $doc->find('.address');
// ... do something with these
There are still some other options, but I think they are less performant:
$sels = $doc->find('h2, .pnlDescription, .address');
foreach($sels as $e) switch(true) {
case $el->hasClass('address'): {
// ...
} break;
case $el->nodeName == 'h2': {
// ...
} break;
}
I would like to have ->is($selector)
method, but have never had the need for it.
Thanks for feedback that's all I need.
How do I filter which element is being processed?
for example, I have mutiple classes: $sels = "h2, .pnlDescription, .address";
I want to have a condition with the ".address" since I want to alter the text within it.
Where and how can I achieve this one?