title: Add two objects into one json_encode in php
body: <p>My try is to make an pagination and thats my ajax request page:</p>
  
  <pre><code>while ($file = $query-&gt;fetch(PDO::FETCH_ASSOC)) {
  
      $arrayFetch[] = [
  
              'id'   =&gt; $file['id'],
              'name' =&gt; $file['name']   
          ];
  
      $lastId = $file['lastId'];
  }
  
  // For simplify: Here is another query code for get the the result of $count
  
  $count = $query-&gt;rowCount();
  </code></pre>
  
  <p>So, I have now the variables <code>$arrayFetch</code> and <code>$count</code>.</p>
  
  <p>UPDATE: </p>
  
  <p>My actually code for json_encode is:</p>
  
  <pre><code>echo '{"user":'.json_encode($arrayFetch).'}';
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>{"user":[{ "id":1,"name":"toby"},....]}
  </code></pre>
  
  <p>what I want is to add an second object like this:</p>
  
  <pre><code>{"user":[{ "id":1,"name":"toby"},....]},
  
  {"pagination":[{ "count":10" }]} // THIS
  </code></pre>
  
  <p>That don't work, it's only an example to show what I try to archive:</p>
  
  <pre><code>echo '{"user":'.json_encode($arrayFetch).'},{ "pagination": [{ "count" : '.$count.' }] ';
  </code></pre>