Forum Moderators: coopster
I am currently snipping after 145 characters, but really mean "go about 140 characters in then snip at the next full stop" (full stop=period for US readers!)
This is what I am using now:
function snip($entry) {
$chars = 145;
$entry = $entry." ";
$entry = substr($entry,0,$chars);
$entry = substr($entry,0,strrpos($entry,' '));
$entry = $entry."...";
return $entry;
}
echo snip$entry;
Can this be done?
function snip($entry) {
$chars = 140;
$entry = substr($entry,0,strpos($entry,'. ', $chars));
$entry = $entry."...";
return $entry;
}
aren't you looking for the first "full stop" after 140 characters?
strrpos would be the last occurence where strpos is the first. Or am I incorrect in what you want?