How would one convert the following array:
[
"prefix1 foo",
"prefix2 bar",
"prefix1 aaa",
"prefix2 bbb",
"prefix3 ccc",
"prefix1 111",
"prefix2 222"
]
into the following data structure:
[
[
"prefix1" => "foo",
"prefix2" => "bar"
],
[
"prefix1" => "aaa",
"prefix2" => "bbb",
"prefix3" => "ccc"
],
[
"prefix1" => "111",
"prefix2" => "222"
],
]
array_chunk would be perfect if not for the fact that the chunks are of variable sizes. The prefixes are known ahead of time and each "chunk" would have a length of either two or three.
explode(), then build a new array with the pieces