我有以下標籤的多個實例的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