title: Trying to update the value of a multidimensional associative array when I only know the location of a child element
body: <p>I am running a recursive function for a multidimensional associative array. I know what I want to do but I can't figure out the right implementation. Let's say I have an array like this:</p>
  
  <pre><code>$my_array = array(
      '1' =&gt; array(
          'id' =&gt; '1',
          'parent' =&gt; false,
          'children' =&gt; array(
              '2' =&gt; array(
                  'id' =&gt; '2',
                  'parent' =&gt; '1',
                  'children' =&gt; array(
                      '3' =&gt; array(
                          'id' =&gt; '3',
                          'parent' =&gt; '2',
                          'children' =&gt; array(
                              //how do I insert an array here if I only have only have the location '3' to work from?           
                          )    
                      )    
                  )    
              )
         )
      )   
  );
  </code></pre>
  
  <p>and I want to insert a new item array inside the child of item 3, but I only have 3 as the location. How do I get to a situation where I can do something like:</p>
  
  <pre><code>$my_array['1']['children']['2']['children']['3']['children'] = $my_array;
  </code></pre>
  
  <p>if I only have '3' as the location to work with and I don't know what the path will be before the '3'? </p>
  
  <p>I thought about converting the array to json and then doing a search for 'id' => '3', and then trying to inject the array as json under the children section, but the problem with this is I couldn't figure out a way on how to find the closing bracket of the json because there could be other closing brackets inside existing children of item 3.</p>