【发布时间】:2016-06-16 10:38:50
【问题描述】:
我想在以下代码的单独的 TR 数组中提取所有 TD 标记
<TR>
<TD class="table_border_both"><B>Person 1</B></TD>
<TD class="table_border_both"><B>Start, 10</B></TD>
<TD class="table_border_both"><B>End , 5</B></TD>
<TD class="table_border_both"><b>14
</b></TD>
</TR>
<TR>
<TD class="table_border_both"><B>Person 2</B></TD>
<TD class="table_border_both"><B>Start, 10</B></TD>
<TD class="table_border_both"><B>End , 5</B></TD>
<TD class="table_border_both"><b>14
</b></TD>
我尝试了这个正则表达式如下
preg_match_all("/([<tr>|\\n]+(<td class=\"table_border_both\"><b>(.*?)<\\/b><\\/td>))/is", $str, $matches);
但我想在 saprate 数组中的所有 TR 如下
[0]=>
array(4) {
[0]=>string(12) "Person 1"
[1]=>string(19) "Start, 10"
[2]=>string(12) "End , 5"
[3]=>string(7) "14
}
[1]=>
array(4) {
[0]=>string(12) "Person 2"
[1]=>string(19) "Start, 10"
[2]=>string(12) "End , 5"
[3]=>string(7) "14
}
【问题讨论】:
标签: php regex parsing html-table