2011-12-27 62 views
0

我想從下面的HTML中獲得<b>Author:</b><br>之間的內容,使用preg_match_all函數,但是它一直返回空數組。我需要中間行HTML輸出,請幫助我。Preg_match_all和html標記

這裏的文字:

<b>Author:</b> <a href="http://link.com" target="_blank" rel="nofollow">Name</a><br /> 

這是我使用的腳本:

preg_match_all("'<b>Author:</b> ([^<]*)<br />'", $page, $preg_author); 
$author = $preg_author[1]; 
print_r($preg_author); 

回答

1

你的正則表達式不能工作,你正在尋找([^ <] *)基本上這將失敗當它會遇到<a標籤,你應該嘗試這一個

基本上它會抓住任何字符(不換行),直到遇到
標籤

+0

它的工作原理!非常感謝你。 – Hubertoss

+0

所以你可以標記我的答案爲接受;) – malko