Jox Technology

Online resource of games, gadgetm and web development

Advertisement

Here’s a very basic function but a very useful one if you need to get text/string between html tags using PHP.

<?php
function getTextBetweenTags($string, $tagname)
{
$pattern = “/<$tagname>(.*?)<\/$tagname>/”;
preg_match($pattern, $string, $matches);
return $matches[1];
}

$str = “<b>123456</b>987″;
$txt = getTextBetweenTags($str,”b”);
echo $txt;
?>

Comments

There are no comments for this post.

Comments are closed.

Write a Comment