title: How to convert $x['a']['b']['c'] = d to $x['a.b.c'] = d easily
body: <p>I have a multiple level array field need to be submit via a form. Not sure what will be the easiest solution:</p>
  
  <p>As php will auto convert dot to underscore, so i change it to array:</p>
  
  <pre><code>$form['a.b_b.c'] ==&gt; &lt;input name="a[b_b][c]" value="$form[a.b_b.c]"&gt;
  </code></pre>
  
  <p>And I got <code>$_POST[a][b_b][c]</code> correctly.</p>
  
  <p>But what is the easiest way to assign this <code>$_POST</code> value back to the original <code>$form['a.b_b.c']</code> without much loops? eg</p>
  
  <pre><code>$form['a.b_b.c'] = $_POST['a']['b_b']['c'];
  </code></pre>
  
  <p>Or is there a better way to walk around?</p>
  
  <p>very close to this question but still not yet:
  <a href="https://stackoverflow.com/questions/9635968/convert-dot-syntax-like-this-that-other-to-multi-dimensional-array-in-php">Convert dot syntax like &quot;this.that.other&quot; to multi-dimensional array in PHP</a></p>
  
  <p>And here is my current solution:</p>
  
  <pre><code>foreach ($form as $k) {
      $form[$k] = assign_val($_POST, $k);
  }
  
  function assign_val($arr = [], $key = '') {
      $keys = explode('.', $key);
      $val = &amp;$arr;
      foreach ($keys as $k) {
          $val = &amp;$val[$k];
      }
      return $val;
  }
  </code></pre>