1

I want to access element of an index of an array but that path or index i have in string i have no idea what to do for example

This is Array

$array = [
    "level1" [
        [
            "level2" => [
                "level3" => [["test1"],["test2"],["test3"],["test4"],["test5"]]
                "lavel3_1 => ...
            ], 
        ],
    ]
    ...
];


This is the index or a path clue

$path = "level1->0->level2->level3->5";

So According to path i have to access like this

print_r($array["level1"][0]["level2"]["level3"][5]);

how to do that because path in a string and its dynamic, do i need to use eval() function

User97798
  • 634
  • 1
  • 5
  • 24

0 Answers0