我一直很困惑。所以这是我的问题,我有这样的文字:
<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];
}
officials of IPB
但是当有 3 个标签时,此代码仅从最后一个标签 () 中检索一个值<ORGANIZATION>
。
现在,我不知道修改此代码以获取标签内的所有值而不会重复。所以请帮忙,提前谢谢。:D