0

I have an array that looks like this:

$array = [
    'key1',
    'key2',
    'key3'
];

Each key in this array is a level in a multidimensional array that is stored on the object. So ideally that multidimensional array would look like this:

protected $map = [
    'key1' => [
        'key2' => [
            'key3'
        ]
    ]
];

I can't just set the multidimensional array because I don't want to overwrite what is already in it. How can I walk through my array and set keys while maintaining th original content of the object property?

revolt_101
  • 395
  • 3
  • 12

0 Answers0