I have a collection of keys in this massive flat single array I would like to basically expand that array into a multidimensional one organized by keys – here is an example:
Input:
[
'invoice/products/data/item1',
'invoice/products/data/item2',
'invoice/products/data/item2',
]
Desired result:
[
'invoice' => [
'products' => ['item1', 'item2', 'item3']
]
]
How can I do this?
The length of the above strings are variable.
Something along these lines:
(Didn’t test it though!)Works now 😉$keys beeing the flat array.