【发布时间】:2011-09-19 08:04:19
【问题描述】:
我正在使用file_get_contents 来读取具有表格的.html 文件。
<table id="someTable" style="width:100%;margin-bottom:0;">
<tr style="display:none;">
<td style="padding-left:25px;">Some text</td>
</tr>
<tr style="display:none;">
<td style="padding-left:25px;">another text</td>
</tr>
</table>
当我使用 preg_match_all 读取表格时,我数 $matches[1] 时一无所获
preg_match_all('/<table id="someTable" style="width:100%;margin-bottom:0;">(.*)<\/table>/', $html, $matches);
$co = count($matches[1]);
【问题讨论】:
-
用正则表达式解析 HTML 几乎肯定不是可行的方法。您希望实现什么目标?
标签: php preg-match preg-match-all