I've been confused. So here's my problem, I have a text like this :
<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.
I'm try to get the value inside <ORGANIZATION>
tag using my code :
function get_text_between_tags($string, $tagname) {
$pattern = "/<$tagname ?.*>(.*)<\/$tagname>/";
preg_match($pattern, $string, $matches);
if(!empty($matches[1]))
return $matches[1];
}
But this code only retrieve one value from the last tag (officials of IPB
) when there are 3 tags <ORGANIZATION>
.
Now, I don't have idea to modify this code to get all value inside tag without duplication. So please help, thanks in advance. :D