I have string:
Main.Sub.SubOfSub
And some kind of data, may be a string:
SuperData
How I can transform it all to this array above?
Array
(
[Main] => Array
(
[Sub] => Array
(
[SubOfSub] => SuperData
)
)
)
Thanks for help,
PK
Given the values
Here’s some code I have lying around that does what you need¹:
See it in action.
¹ Actually it does slightly more than that: it can be trivially encapsulated inside a function, and it is configurable on all three input values (you can pass in an array with existing values, and it will expand it as necessary).