title: Turn array into multidimensional assoc array
body: <p>I have a problem with creating a dynamic assoc array based on a string.</p>
  
  <p><strong>For example the following piece of code:</strong></p>
  
  <pre><code>Session::addSession('browser.history','stackoverflow');
  </code></pre>
  
  <p>This should return the following array: $_SESSION[TL_MODE]['browser']['history'] = 'stackoverflow';</p>
  
  <p><strong>Current addSession function:</strong></p>
  
  <pre><code>public static function addSession($type, $value) {
              $_SESSION[TL_MODE][$type] = $value;
      }
  </code></pre>
  
  <p>I have been working on this for a couple of days and I still don't have a solution.</p>
  
  <p>I hope someone could help me solve this problem, or if my approach is just wrong, I would like to know how I can achieve the same goal with a different approach.</p>
  
  <p><strong>---UPDATE---</strong></p>
  
  <p>Thanks to someone who saw this was a duplicated question. This is how I fixed it for my situation:</p>
  
  <pre><code>$temp = &amp;$_SESSION[TL_MODE];
          $exploded = explode('.', $path);
          foreach($exploded as $key) {
              if(!is_array($temp[$key])) {
                  $temp[$key] = array();
              }
              $temp = &amp;$temp[$key];
          }
          $temp[] = $value;
          unset($temp);
  </code></pre>