php - How to select all elements except specific one? -
i have structure this:
<div>     <span>         <a class="test">one</a>     </span>     <a>two</a>     <a>three</a> </div> and here code:
$data = $html->find('div', 0); foreach($data->find('a') $article){   echo $word .= $article->plaintext."<br>"; } and here current result:
one 2 3 and here expected result:
two 3 as see in above result, want select <a> element except 1 has test classname. how can that?
note: use this php library.
my suggestion (didn't test it):
$data = $html->find('div', 0); foreach($data->find('a') $article){   if($article->getattribute('class') != 'test'){     echo $word .= $article->plaintext."<br>";   } } 
Comments
Post a Comment