Skip to content

Instantly share code, notes, and snippets.

@benplum
Last active August 29, 2015 13:59
Show Gist options
  • Save benplum/10982102 to your computer and use it in GitHub Desktop.
Save benplum/10982102 to your computer and use it in GitHub Desktop.
Paragraph Trim Functions
function getFirstPP($html) {
$start = strpos($html, '<p');
$end = strpos($html, '</p>', $start);
$html = substr($html, $start, ($end - $start + 4));
return $html;
}
function splitFirstPP($html) {
$parts = explode("</p>", $html, 2);
$first = $parts[0] . "</p>";
$rest = $parts[1];
return array($first, $rest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment