0

For example, i have this array:

$arr = [
    'a' => [
        'b' => [
            'c' => 100
        ]
    ]
];

I want to somehow pass all the indexes in a string dynamically like

$str = 'a.b.c'

and use this string to access the array with the string, how can i do it?

I tried something like:

$arr[explode('.', 'a.b.c')]

But of course it didn't work.

3
  • is it always exactly 3? Commented Feb 3, 2022 at 16:44
  • no, it's how many it's necessary Commented Feb 3, 2022 at 16:45
  • 1
    I believe this one is a "better duplicate" of OP's question: Flatten multidimensional array concatenating keys Commented Feb 3, 2022 at 16:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.