title: How to assign array variable using explode value in PHP?
body: <p>This is my sample.json file</p>
  
  <pre><code>  "general": {
      "option_name" : "option_name",
      "filter_name" : "filter name"
  }
  </code></pre>
  
  <p>and I want to update the value using key</p>
  
  <pre><code>$string = "general.filter_name";
  
  $updateContent = "new filtername";
  
  $langArray = explode('.',$string);
  
  print_r($langArray);
  
  /*Array
  (
  [0] =&gt; general
  [1] =&gt; filter_name
  ) */
  
  
  $file='assets/sample.json';
  
  $jsonString = file_get_contents($file);
  $data = json_decode($jsonString, true);
  
  **$data['general']['filter_name'] = $updateContent; **
  
  
  $newJsonString = json_encode($data);
  file_put_contents($file, $newJsonString);
  </code></pre>
  
  <p>Here I want to assign Array</p>
  
  <pre><code> [0] =&gt; general
   [1] =&gt; filter_name
  </code></pre>
  
  <p>should be  </p>
  
  <pre><code>$data['general']['filter_name']
  </code></pre>
  
  <p>How to define array like this? Thanks</p>