A smart substring PHP function to avoid break-words