How to access and manipulate multi-dimensional array by key names / path?
问题 I've to implement a setter in PHP, that allows me to specify the key, or sub key, of an array (the target), passing the name as a dot-separated-keys value. Given the following code: $arr = array('a' => 1, 'b' => array( 'y' => 2, 'x' => array('z' => 5, 'w' => 'abc') ), 'c' => null); $key = 'b.x.z'; $path = explode('.', $key); From the value of $key I want to reach the value 5 of $arr['b']['x']['z'] . Now, given a variable value of $key and a different $arr value (with different deepness). How