Possible Duplicate:
How to get first x chars from a string, without cutting off the last word?
php trim a string
My issue is that i need cut a string down to less than 30 characters whilst also making sure that the string finishes on a word.
I have been using this:
$slidedescription = substr($slidedescription,0,30).'...';
The problem is that it can cut into the string mid word. Is there any simple way to make sure that it finished on a word but it less than 30 characters long?
There can be many unexpected situations i tried to cover as many as i can them up: