Here’s a useful PHP function to return the first paragraph from a HTML text string. It involves finding the character position of the first closing “p” tag from the first paragraph.
Add the following function somewhere in you PHP (I usually have a global functions file).
")+4); return $string; } ?>
Then call the function, passing the string variable:
If you wanted to remove the paragraph tags from the HTML, the function would change to:
")+4); $string = str_replace("
", "", str_replace("", "", $string)); return $string; } ?>