title: Decode and update a JSON array in PHP
body: <p>I need to update my JSON array in the file jsonData_0_123.json. I can get the data from the file and decode it, but I can't update the data in the file (in this case, the array answers)</p>
  
  <pre><code>$contents = file_get_contents('json_files/jsonData_0_123.json');
  
  //Decode the JSON data into a PHP array.
  $contentsDecoded = json_decode($contents, true);
  
  //Update the decoded array
  $contentsDecoded[1]["answers"] = "hello";
  
  //Encode the array back into a JSON string.
  $json = json_encode($contentsDecoded);
  
  //Save the file.
  file_put_contents('json_files/jsonData_0_123.json', $json);
  </code></pre>