title: Using func_get_args to edit an array
body: <p>I wish to use a function with an arbitrary number of arguments to edit an array.  The code I have so far is:</p>
  
  <pre><code> function setProperty()
   {
    $numargs = func_num_args();
    $arglist = func_get_args();
    $toedit = array();
    for ($i = 0; $i &lt; $numargs-1; $i++)
    {
     $toedit[] = $arglist[$i];
     }
     $array[] = $arglist[$numargs-1];
   }
  </code></pre>
  
  <p>The idea of the code being I can do the following:</p>
  
  <pre><code>setProperty('array', '2nd-depth', '3rd', 'value1');
  setProperty('array', 'something', 'x', 'value2');
  setProperty('Another value','value3');
  </code></pre>
  
  <p>Resulting in the following array:</p>
  
  <pre><code>Array
  (
      [array] =&gt; Array
          (
              [2nd-depth] =&gt; Array
                  (
                      [3rd] =&gt; value1
                  )
  
              [something] =&gt; Array
                  (
                      [x] =&gt; value2
                  )
  
          )
  
      [Another Value] =&gt; value3
  )
  </code></pre>
  
  <p>The issue I believe is with the line: </p>
  
  <pre><code>$toedit[] = $arglist[$i];
  </code></pre>
  
  <p>What does this line need to be to achieve the required functionality?</p>
  
  <p>Cheers,</p>