title: How to set a deep array in PHP
body: <p>Assume I have the following function</p>
  
  <pre><code>function setArray(&amp;$array, $key, $value)
  {
      $array[$key] = $value;     
  }
  </code></pre>
  
  <p>In the above function, key is only at the first level, what if I want to set the key at the 2nd or 3rd levels, how to rewrite the function?</p>
  
  <p>e.g.</p>
  
  <pre><code> $array['foo']['bar'] = 'test';
  </code></pre>
  
  <p>I want to use the same function to set the array value</p>