I was searching like mad and found no solution. The problem is simple.

Let's say I have 3 DIVs:

<div class="class1">
  <div class="subclass"> TEXT1 </div>
</div>

<div class="class2">
  <div class="subclass"> TEXT2 </div>
</div>

<div class="class1 class2">
  <div class="subclass"> TEXT3 </div>
</div>

So, very simple. I just want to find the TEXT3, which has BOTH class1 and class2. Using Simple HTML DOM Parser, I can't seem to get it to work.

Here's what I tried:

foreach($html->find("[class=class1], [class=class2]") as $item) {
$items[] =  $item->find('.subclass', 0)->plaintext;
}

The problem is, with

find("[class=class1], [class=class2]")

it's finding all of them, as the comma is like an OR, if I leave the comma, it's looking for nested class2 inside class1. I am just looking for an AND...

EDIT

Thanks to 19greg96 I found out that

div[class=class1 class2]

works, the problem is that it looks for exactly those two in that order. Let's say I have

<div class="class1 class2">
  <div class="subclass"> TEXT3 </div>
</div>

then it works, and if I have

<div class="class1 class2 class3">
  <div class="subclass"> TEXT3 </div>
</div>

it works when I put an asterix, as it looks for the substring:

div[class*=class1 class2]

PROBLEM

I know only that class1 and class3 is there, but maybe others and in random order. That still doesn't work. Any idea how to just look for A & B in any random order? So that

div[class=class1 class3]

works with that example?

Edit
Report