How do I recursively get value from array where I need to explode a key? I know, it's not good the question, let me explain.
I got an array
[
"abc" => "def",
"hij" => [
"klm" => "nop",
"qrs" => [
"tuv" => "wxy"
]
]
]
So, inside a function, I pass:
function xget($section) {
return $this->yarray["hij"][$section];
}
But when I want to get tuv
value with this function, I want to make section as array, example:
To get hij.klm
value (nop
), I would do xget('klm')
, but to get hij.klm.qrs.tuv
, I can't do xget(['qrs', 'tuv'])
, because PHP consider $section
as key, and does not recursively explode it. There's any way to do it without using some if
s and $section[$i]
?