Revision: 47116
Updated Code
at September 18, 2013 04:26 by adamturtle
Updated Code
/* @param: $len - number of sentences to return @param: $content - string to be returned */ function limit_sentences($len, $content){ $content = preg_split('/[\.\!\?]\s{1}/',$content); $o = null; for($i=0;$i<$len;$i++){ $o.= $content[$i] . '. '; } return $o; }
Revision: 47115
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 1, 2011 07:13 by adamturtle
Initial Code
/* @param: $content - string to be returned @param: $sentences - number of sentences to return */ function limit_sentences($content, $sentences) { $text = html_entity_decode(strip_tags($content)); $text = explode('.', $text); for( $i=1; $i<=$sentences; $i++ ){ $output .= $text[$i] . '. '; } if($output){ return $output; } else { return $content; } }
Initial URL
Initial Description
A simple function that will split a given string into sentences, and then return the number of sentences specified. Quick and dirty.
Initial Title
String to sentences function
Initial Tags
php
Initial Language
PHP