Question: I have this exath path saved somewhere:

```
Array
(
    [0] => library
    [1] => 1
    [2] => book
    [3] => 0
    [4] => title
    [5] => 1
)

```

I have some array and I want to change the value on this index:

```
$values[library][1][book][0][title][1] = "new value";

```

I have no idea, how to do this, because there can be any (unknown) number of dimensions. Any hints?

Answer: 
Try

```
foreach ($array as $val) {
   $indexes .= "[$val]";
}
${'output'.$indexes} = 'something';

```

Or

```
$indexes = '';
foreach ($array as $val) {
   $indexes .= "[$val]";
}
$output = 'values'.$indexes;
$$output = 'something';

```
try this ->

```
$keys = array('0'=>'for','1'=>'test','2'=>'only');
$value='ok';

function addArrayPathWithValue($keys,$value,$array = array(),$current = 
array())
{
    $function = __FUNCTION__;

    if (count($current)==0)
    {
        $keys = array_reverse($keys);
        $current = $value;
    }

    if (count($keys)==0)
    {
       return $current;
    }

    $array[array_shift($keys)]=$current;

    return $function($keys,$value,NULL,$array);
}

$array = addArrayPathWithValue($keys,$value);
print_r($array);
//output: Array ( [for] => Array ( [test] => Array ( [only] => ok ) ) )

```