I have an array with string with certain lenght of characters:
Array
(
[0] => foo
[1] => bar
[2] => hello
[3] => world
[4] => i
[5] => great
)
I need to combine those values into chunks until some string length limit is reached.
For example max char number is 6
So new array would look like this
Array
(
[0] => foobar
[1] => hello
[2] => worldi
[3] => great
)
"Foo" and "Bar", "i" and "world" merges, because it does not exceed 6 max allowed char limit. However "Hello" don't because combined char limit exceeds 6.
Can't wrap my head around how to do it.