I want to explode a string by (for example) 50 symbols (min), but without dividing words in 2 parts.
Is this possible?
Using str_split() will cause the last word to get split, which is what I don’t want.
Example: splitting string by 5 symbols;
$input = 'This is example, example can be anything.';
$output[0] = 'This';
$output[1] = 'is example,';
$output[2] = 'example';
$output[3] = 'can';
$output[4] = 'be anything';
I don’t think there’s a single built-in function that will do it for you, but you could do something like this:
Codepad Example Here