title: PHP: Set value of nested array using variable as key
body: <p>Lets say i have this kind of code:</p>
  
  <pre><code>    $array = [
          'a'=&gt; [
              'b' =&gt; [
                  'c'=&gt;'some value',
              ],
          ],
      ];
  
      $array['a']['b']['c'] = 'new value';
  </code></pre>
  
  <p>Of course this is working, but what i want is to update this 'c' key using variable, something like that:</p>
  
  <pre><code>$keys = '[a][b][c]';
  $array{$keys} = 'new value';
  </code></pre>
  
  <p>But keys are treatening as string and this is what i get:</p>
  
  <pre><code>$array['[a][b][c]'] = 'new value';
  </code></pre>
  
  <p>So i would like some help, to show me the right way to make this work without using eval().</p>
  
  <p>By the way, there can be any number of array nests, so something like this is not a good answer:</p>
  
  <pre><code>$key1 = 'a';
  $key2 = 'b';
  $key3 = 'c';
  $array[$key1][$key2][$key3] = 'new value';
  </code></pre>