title: How to add to JSON array in .json file
body: <p>How do I add to a .json file with PHP? Currently, I'm appending a .json file with PHP, but it won't add the data to an existing JSON object. It makes a new object. I need the data all stored in one object, in an external JSON file. Basically, I have a JSON object and want to add more values to it.</p>
  <pre><code>$jsonFile = &quot;test.json&quot;;
  $fh = fopen($jsonFile, 'w');
  
  $json = json_encode(array(&quot;message&quot; =&gt; $name, &quot;latitude&quot; =&gt; $lat, &quot;longitude&quot; =&gt; $lon, &quot;it&quot; =&gt; $it));
  
  fwrite($fh, $json);
  </code></pre>