Created
May 14, 2014 19:19
-
-
Save ezrabrook/777ccb5c888ad5539cad 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
function hdfs_summarise($paragraph, $limit) { | |
$textfield = strtok($paragraph, " "); | |
while ($textfield) { | |
$text .= " $textfield"; | |
$words++; | |
if (($words >= $limit) && ((substr($textfield, -1) == "!") || (substr($textfield, -1) == "."))) { | |
break; | |
} | |
$textfield = strtok(" "); | |
} | |
return ltrim($text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added to the template.php in a drupal theme to truncate the body that it is put on in a theme like