title: php create array (dimensions/path) from different array-keys
body: <p>I hope the title is not too bad. I'm not an english person and this would even be hard to put in one sentece in my mothertounge...</p>
  
  <p>My problem is follwing:</p>
  
  <p>Iwant to build a multidimensional array from a string like so:</p>
  
  <pre><code>$string = "a-b-c";
  $val = "something";
  
  $array['a']['b']['c'] = $val;
  </code></pre>
  
  <p>I tried some ideas of mine and ended up with a fried brain...
  Hopefully you can help me! Thanks!</p>
  
  <p><strong>EDIT</strong> 
  My approach:</p>
  
  <pre><code> function recursion($c, $p, $v) {
          if (gettype($c) !== "array") $c = array();
          $c[$p] = $v;
          return $c;
      }
  
      foreach ($conf as $confLine) {
          $params = preg_split('/-/', $confLine-&gt;getParam());  //Here comes "a-b-c"
          $val = $confLine-&gt;getValue();  // The value 
  
          for ($i = 0; $i &lt; count($params); $i++ ) {
              $galleryConfig = recursion($galleryConfig, $params[$i], $val);
          }
      }
  </code></pre>
  
  <p><strong>IMPORTANT</strong>
  I don't know how long the sting will be. If its a-b or a-b-c-d-e-f</p>