我试图从id为sid-120390923
或sid-38737122
的表中获取td字段,忽略表中的任何其他id值,但问题是我无法获取这些td字段,因为它们的id略有不同,但起点相同("id")。
我想要的是能够获取所有起始id为sid-
的td字段,有没有办法合并regex?
这是一个的例子
html
<table>
<tr>
<td id='9sd'></td>
<td id='10sd'></td>
<td id='sid-1239812983'></td>
<td id='sid-1454345345'></td>
<td id='sid-2342345234'></td>
<td id='sid-5656433455'></td>
<td id='sid-1231235664'></td>
<td id='sid-8986757575'></td>
<td id='sid-1232134551'></td>
</tr>
</table>
simple_html_dom
$table = $con->find('table');
foreach($table->find('td#sid-1232134551') as $field){
echo $field."<br>";
}
您可以使用属性过滤器(5。选项卡),
$table->find('td[id^=sid-]');