Mega Code Archive

 
Categories / Php / Strings
 

Capturing Text Inside HTML or XML Tags

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