Hi there,

I have written a script that automatically chops off anything over 100 characters and I have the following line in there to make sure it does so at the last full word:

PHP Code:
$truncated substr($longstring,0,strpos($longstring,' ',100)); 
This ensures that I'm not chopping in the middle of a word - It counts back to the last space before the 100th character.

I want to change this so that it counts back to the last full stop before the 100th character so that I can enhance the script even more and truncate at the end of a sentence rather than the end of a word.

I have tried replacing

PHP Code:
$truncated substr($longstring,0,strpos($longstring,' ',100)); 
with

PHP Code:
$truncated substr($longstring,0,strpos($longstring,'.',100)); 
but it doesn't work...

How can I tell it to count back to the last full stop instead of the last space?