title: JSON in This Format in PHP
body: <p>I'm working on a project that needs to add JSON to the file after every form submission.
  My goal is to get the JSON to look like:</p>
  
  <pre><code>{
    "word0":[
      "cheese",
      "burger"
    ],
  
    "word1":[
      "sup",
      "boi"
    ],
  
    "word2":[
      "nothin'",
      "much"
    ]
  }
  </code></pre>
  
  <p>But I'm not able to add to the JSON file afterwards.</p>
  
  <p>EDIT: I'm thinking about just creating a new file for every form submission.  Would this be a better option?
  (Storage size isn't a problem)</p>
  
  <p>Here's my current code that places JSON into a file:</p>
  
  <pre><code>$response['word' . $count] = array('word1' =&gt; $_POST['firstrow'], 'word2' =&gt; $_POST['secondrow']); 
  file_put_contents("query.json", file_get_contents("query.json") . json_encode($response) . "\n");
  </code></pre>