title: Convert a string into an associative array key?
body: <p>Given a string that contains values separated by dots:</p>
  
  <pre><code>property.entry.item
  </code></pre>
  
  <p>What is the best way to convert that to a key for an associative array?</p>
  
  <pre><code>$result['imported_data']['property']['entry']['item']
  </code></pre>
  
  <p>The string may be of any length, with any number of dots and contain an value:</p>
  
  <pre><code>people.arizona.phoenix.smith
  </code></pre>
  
  <p>I've tried the following without success:</p>
  
  <pre><code>//found a dot, means we are expecting output from a previous function
  if( preg_match('[.]',$value)) {
  
      //check for previous function output
      if(!is_null($result['import'])) {
  
          $chained_result_array = explode('.',$value);
  
          //make sure we have an array to work with
          if(is_array($chained_result_array)) {
  
              $array_key = '';
              foreach($chained_result_array as $key) {
  
                  $array_key .= '[\''.$key.'\']';
              }
  
          }
          die(print_r(${result.'[\'import\']'.$array_key}));
      }
  }
  </code></pre>
  
  <p>I was thinking I could convert the string to a variable variable, but I get an array to string conversion error.</p>