I'm struggeling second day with transforming dot to tree structure. Can anyone help?
$input = [
'inbox' => ['name' => 'Inbox'],
'inbox.first' => ['name' => 'First'],
'inbox.second' => ['name' => 'Second'],
'inbox.second.other' => ['name' => 'Second Other'],
'inbox.third.another' => ['name' => 'Third Another'],
];
$expectedOutput = [
'inbox' => [
'name' => 'Inbox',
'mailbox' => 'inbox',
'subfolders' => [
'first' => [
'name' => 'First',
'mailbox' => 'inbox.first',
'subfolders' => [],
],
'second' => [
'name' => 'Second',
'mailbox' => 'inbox.second',
'subfolders' => [
'other' => [
'name' => 'Second Other',
'subfolders' => [],
'mailbox' => 'inbox.second.other',
],
],
],
'third' => [
'subfolders' => [
'another' => [
'name' => 'Third Another',
'subfolders' => [],
'mailbox' => 'inbox.third.another',
],
],
],
],
],
];