/ Published in: PHP
A simple function that will split a given string into sentences, and then return the number of sentences specified. Quick and dirty.
Expand |
Embed | Plain Text
/* @param: $content - string to be returned @param: $sentences - number of sentences to return */ function limit_sentences($content, $sentences) { for( $i=1; $i<=$sentences; $i++ ){ $output .= $text[$i] . '. '; } if($output){ return $output; } else { return $content; } }
You need to login to post a comment.
