Imagine I have 150 characters long string. I would like to divide it into 3 parts, each max 50 characters long. The trick is I also have to keep words intact while dividing the string into 3 parts.
I could use substr
and check if it cut the word into half or not. I would like to know if there is any other elegant way to do this.
I also have to keep it in mind that the string might have less than 150 characters. For example if it is 140 characters long then it should be 50 + 50 + 40.
In case if it is less than 100 than it should be 50 + 50. If it is 50 characters or less it shouldn't divide the string.
I would be glad to hear your ideas / ways to approach this.
Thank you in advance for your time and concern.