我有以下标签的多个实例的HTML页面中提取标签的最有效的方法:从多个字符串
<INCLUDEFILE-1-/var/somepath/file1.php>
<INCLUDEFILE-2-/var/somepath/file2.php>
<INCLUDEFILE-3-/var/somepath/file3.php>
<INCLUDEFILE-4-/var/somepath/file4.php>
<INCLUDEFILE-5-/var/somepath/file5.php>
可以使用哪些代码提取所有上述的路径?我迄今得到了下面的代码,但不能让它正常工作:
preg_match_all('/INCLUDEFILE[^"]+/m', $html, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[0]); $i++)
{
$includefile = $result[0][$i];
}
我需要提取:
/var/somepath/file1.php
/var/somepath/file2.php
/var/somepath/file3.php
/var/somepath/file4.php
/var/somepath/file5.php
任何人都可以看到明显的错误(S)?
你真的是说'FILEINCLUDE'在你的正则表达式,而不是'INCLUDEFILE' – 2013-04-10 18:44:52
?感谢罗伯特指出了这一点......我会纠正和澄清 – Alex 2013-04-10 18:48:39