Wednesday, 25 September 2013

How to get DIVs with certain class and also without?

How to get DIVs with certain class and also without?

I've got this HTML:
<div class="hello top">some content</div>
<div class="hello top">some content</div>
<div class="hello">some content</div>
<div class="hello">some content</div>
<div class="hello">some content</div>
... and i am trying to get only those DIVs which has class "hello" but not
class "top" (i want 3 last DIVs only to get).
I tried something like this but without success:
foreach( $html->find('div[class="hello"], div[class!="top"]') as $element ) {
// some code...
}

No comments:

Post a Comment