PHP to get content between in html tag
by Subramanian[ Edit ] 2014-05-03 18:04:24
PHP to get content between in html tag:
The below php function is used to get the content between html tags.
For Example :
if the original string is like, "This is <b>GvSubhu</b>" then get the value in "b" tag.
function getTextBetweenTags($string, $tagname) {
$pattern = "/<$tagname ?.*>(.*)$tagname>/";
preg_match($pattern, $string, $matches);
return $matches[1];
}
echo getTextBetweenTags("This is <b>GvSubhu</b>", b);
Output :
GvSubhu
hioxd
Good one....
0
0
Add Reply