I want to truncate/shorten my string to the sentence closest to a ceratain number of characters.
I have a working function, but my function truncate to the word clos
You could just use a simple regular expression like /^([^.]*?).*/ and replace that with "$1". Like:
/^([^.]*?).*/
$output = preg_replace('/^([^.]+).*/', '$1.', $input);
That said, you'll have to be aware that not all languages have period (.) as the sentence delimiter.
HTH.