Let's assume we have a simple $array like the following.
$array = array(
    'a' => array(
        'b' => array(
            'c' => 'd'
        ),
        'e' => 'f'
    ),
    'g' => 'h'
);
Given an arbitrary array of $keys = array('a', 'b', 'c') and a value $value = 'i', I would like to change value of $array['a']['b']['c'] to i.
For simplicity, let's assume that elements of $keys are all valid, i.e. for any positive j, $keys[j] exists and is a child of $keys[j - 1].
I came up with a solution by passing a reference to the array and looping over keys but my implementation seems a bit ugly. Is there any straight forward way of doing this?
 
    