Im looking for a soluting for the followting case. I have a string
"This is a long string of words"
I want to use only the first few words, but if I just cut everything after 20th character, it will look like this:
"This is a long strin"
I can grab first 3 words
implode(' ', array_slice(explode(' ', "This is a long string of words"), 0, 3));
But in some cases, 3 words are going to be too short "I I I".
How can I grab as many words as possible before 20th character?