我一直很困惑。因此,這裏是我的問題,我有這樣的文字:檢查標籤並使用PHP獲取標籤內的值
<ORGANIZATION>Head of Pekalongan Regency</ORGANIZATION>, Dra. Hj.. Siti Qomariyah , MA and her staff were greeted by <ORGANIZATION>Rector of IPB</ORGANIZATION> Prof. Dr. Ir. H. Herry Suhardiyanto , M.Sc. and <ORGANIZATION>officials of IPB</ORGANIZATION> in the guest room.
我嘗試使用我的代碼進去<ORGANIZATION>
標籤值:
function get_text_between_tags($string, $tagname) {
$pattern = "/<$tagname ?.*>(.*)<\/$tagname>/";
preg_match($pattern, $string, $matches);
if(!empty($matches[1]))
return $matches[1];
}
但這個代碼只檢索從一個值當有3個標籤<ORGANIZATION>
時,最後一個標籤(officials of IPB
)。
現在,我不知道要修改此代碼以獲取標籤內的所有值而不重複。所以請提前幫助,謝謝。 :D
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – 2013-05-09 03:58:00
@MatthewGraves我不明白這篇文章(我的英語不好)。有沒有希望? – andrefadila 2013-05-09 04:03:44
爲什麼我得到的投票下來:( – andrefadila 2013-05-09 04:41:28