title: array_merge before json encode in PHP
body: <pre><code>$myArray = array();
  
  for($i=0;i&lt;2;$i++){
  ..
  .. //get the content logic here
  
  assign it to array
  $myArray["item"]["content"] = $item_content;
  }
  echo json_encode($myArray);
  </code></pre>
  
  <p>The above code produced this result:</p>
  
  <p><img src="https://i.stack.imgur.com/ls7LQ.png" alt="enter image description here"></p>
  
  <p>Which has an error because I didn't merge them.</p>
  
  <p>I tried to merge like this:</p>
  
  <pre><code>$finalJson = array_merge($finalJson, $myArray); 
  </code></pre>
  
  <p>but the output of <code>echo $finalJson</code> is one object instead of 3. </p>