I have been scratching my head on this but cannot work out a solution.
Let's say you have a text of 5000 characters, I would like to split it into blocks of less than 500 characters, but, without breaking a single sentence. eg: if a paragraph is let's say 550 words and the last sentence stops at 550 characters but start at 450 characters, I would like to save this particular block to a maximum of 450 characters(this way no sentences are broken).
Any idea how to achieve this please?
My goal is to save each block into an array so I can work on them separately.
I was thinking about using preg_split, sum the outputs, and if the sum is above 500 characters, remove the last sum. But.....I find it difficult to separate the sentences without mistakes.
Any idea what preg_split rules I should use to make sure that every single sentences are well separated?
I tried to use this tool but cannot get it to give me the right output: https://www.phpliveregex.com/#tab-preg-split
Thanks