これを試して:
foreach($html->find('[class=hello]') as $found)
それがうまくいかない場合は、このエレガントさは劣りますが、まだ機能するアプローチをいつでも実行できます。
foreach($html->find('.hello') as $found)
{
if ($found->class != 'hello')
continue;
//do stuff here
}
HTML要素を見つける方法という見出しの下で、この種のものについて詳しく知ることができますか? マニュアルで。属性セレクターは非常に強力です。こちらを参照してください。
[attribute] Matches elements that have the specified attribute.
[attribute=value] Matches elements that have the specified attribute with a certain value.
[attribute!=value] Matches elements that don't have the specified attribute with a certain value.
[attribute^=value] Matches elements that have the specified attribute and it starts with a certain value.
[attribute$=value] Matches elements that have the specified attribute and it ends with a certain value.
[attribute*=value] Matches elements that have the specified attribute and it contains a certain value.