title: Create infinitely deep multidimensional array from string in PHP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8537148/string-with-array-structure-to-array">String with array structure to Array</a>  </p>
  </blockquote>
  
  
  
  <p>I have a string "db/yum/user", and I'm trying to explode it so each element of / becomes a deeper dimension.</p>
  
  <p>So the direct method of creating the data variable would be</p>
  
  <pre><code>$config['db']['yum']['user'] = "val";
  </code></pre>
  
  <p>My attempt so far:</p>
  
  <pre><code>$config = array();              
    function set_config($key,$value){
  global $config;
  
          //Multi deminsional config
          $multi_configs = explode('/',$key);
          if($multi_configs!==false){
              $build_up = array();
              $c =&amp; $build_up;
  
              foreach($multi_configs as $multi_config){
                  $c[$multi_config] = array();
                  $c     =&amp; $c[$multi_config];
              }
              //$c = $value;
              array_merge($config,$c);
              return;
          }
  
  
          $config[$key] = $value;
      }
                 set_config('db/yum/user','val');
                 set_config('db/yum/server','val2');
                  //etc,etc,etc, this was modified to make more sense in this context.
  </code></pre>