This is a WordPress-specific context but my question is more PHP-related...
I'm finding myself in an odd situation where I need to get a value deep inside a multidimensional array, using another array that contains the sequence of keys in the correct order.
So essentially I have an array the looks something like
[0] => 'neighborhood' [1] => 'street' [2] => 'house'
And ultimately what I need is
get_option( $options_id )['neighborhood']['street']['house']
So basically I need to get the value of 'house'
from the Options array by using another array to recurse down to it.
I can't do something like
foreach ( $array as $value ) {
$sequence .= '[' $value ']';
}
get_option( $options_id ) . $sequence;
because that would fill $sequence
with the values as a string. I've been trying things with explode()
without any luck, but I'm not really a PHP wizard so I'm hoping there's some kind of obvious answer that I just haven't encountered before.
I know it's a weird situation but any help would be much appreciated!