Created
August 9, 2010 11:16
-
-
Save evadne/515293 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function arGenerateExcerpt ($incomingText = "", $maximumAllowedLength = 75, $wrapperElementTagName = "p") { | |
$responseText = ""; | |
$contentInParagraphs = explode("</" . $wrapperElementTagName . ">", $incomingText); | |
foreach ($contentInParagraphs as $paragraph) { | |
$responseText .= strip_tags($paragraph, "<p>") . "</" . $wrapperElementTagName . ">"; | |
if ((u8strlen($responseText) + u8strlen($paragraph)) >= $maximumAllowedLength) | |
break; | |
} | |
return strip_tags($responseText); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment