f.e我们有tr,td这样,我想用preg_match_all来选择一些数据
<tr data-tag="tagid1" class="role-odd" role="row">
<td class="sorting_1">pos</td>
<td class="member_name" data-tag="tagid1">nick1</td>
<td>rank1</td>
<td>tagid2</td>
<td class="right aligned">points</td>
<td class="right aligned">lvl</td>
<td data-sort="points">
<img class="ui mini image" src="link" alt="desc">
</td>
<td class="right aligned" data-sort="points2">points2</td>
<td class="right aligned" data-sort="points3">points3</td>
<td>
<div class="">
<input id="compare-checkbox-tagid1" class="compareme" data-tag="tagid1" data-name="nick" type="checkbox">
</div>
</td>
</tr>
<tr data-tag="tagid2" class="role-even" role="row">
<td class="sorting_1">pos</td>
<td class="member_name" data-tag="tagid2">nick2</td>
<td>rank2</td>
<td>tagid2</td>
<td class="right aligned">points</td>
<td class="right aligned">lvl</td>
<td data-sort="points">
<img class="ui mini image" src="link">
</td>
<td class="right aligned" data-sort="points">points2</td>
<td class="right aligned" data-sort="points3">points3</td>
<td>
<div class="">
<input id="compare-checkbox-tagid2" class="compareme" data-tag="tagid2" data-name="nick" type="checkbox">
</div>
</td>
</tr>
如果我使用以下代码
preg_match_all('#<tr[^>]+>(.+?)</tr>#ims',$out,$top);
$ top包含所有trs
,但我不需要所有数据,我想要以下数据:pos,nick,rank,tagid,points,lvl,points2,points3
任何人都可以帮助我吗?
答案 0 :(得分:0)
您想要获取<td>
的所有内容吗?
您可以尝试常规#<td.*?>(.*)<\/td>#