PHP Capturing Text Inside Html Or Xml Tags – String Function

<?php $text = "<p>This is some text here \"</p>\".</p>";
ereg("<p>(([^<\"]|[^<]*<[^\/][^<])*(\"[^\"]*\"([^<\"]|[^<]*<[^\/][^<])*)*)?<\/p>", $text, $matches);
echo "Found text: " . $matches[1] . "\n";
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.