title: array_merge(): Argument #1 is not an array
body: <p>need your help on this... got an error on my array_merge
  here's my code:</p>
  
  <pre><code>//first
      $url1="https://www.zopim.com/api/v2/chats";
      $ch1 = curl_init();
      curl_setopt($ch1, CURLOPT_URL, $url1);
      curl_setopt($ch1, CURLOPT_USERPWD, "$username:$password");
      curl_setopt($ch1, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
      $output1 = curl_exec($ch1);
      $info1 = curl_getinfo($ch1);
      curl_close($ch1);
  
      $chats1 = json_decode($output1,true);
  
      //second
      $url2="https://www.zopim.com/api/v2/chats?page=2";
      $ch2 = curl_init();
      curl_setopt($ch2, CURLOPT_URL, $url2);
      curl_setopt($ch2, CURLOPT_USERPWD, "$username:$password");
      curl_setopt($ch2, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
      $output2 = curl_exec($ch2);
      $info2 = curl_getinfo($ch2);
      curl_close($ch2);
  
      $chats2 = json_decode($output2,true);
  
  
  
      $r = [];
      if(is_array($chats1) &amp;&amp; is_array($chats2))
      {
          foreach($chats1 as $key =&gt; $array)
          {
              $r[$key] = array_merge($chats2[$key], $array);
          }
      }
      else
      {
      echo 'problem with json';
      }
      echo json_encode($r, JSON_UNESCAPED_SLASHES);
  </code></pre>
  
  <p>I need to combine a two json using array_merge()... im using curl authorization to call my API..</p>
  
  <p>but when i try to run the code it has a error:
  <a href="https://i.stack.imgur.com/vSc1x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vSc1x.png" alt="enter image description here"></a></p>
  
  <p>here's number 44 error:
  <a href="https://i.stack.imgur.com/kNWJa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kNWJa.png" alt="enter image description here"></a></p>