title: How to change string into JSON format structure using PHP?
body: <p>I have these code to pull data from two different database. </p>
  
  <p>And I need to eliminate the same row by 'staffid'.</p>
  
  <p>So far I can eliminate the duplicate. But the output is not what I want it to be.</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php
  
      // PART A
      require 'conn.php';
      $query = "SELECT STAFFID FROM TABLE";
      $result = oci_parse($conn, $query);
      oci_execute($result);
      while ($row = oci_fetch_array($result,OCI_NUM)){
          $arr[] = $row[0]; 
      } 
  
  
      // PART B
      $url="http://localhost/fetch_data.php";  
      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
      curl_setopt($ch, CURLOPT_URL,$url); 
      $result=curl_exec($ch); 
      curl_close($ch); 
  
  
      foreach(json_decode($result) as $result2)
      {
          if(!in_array($result2[0],$arr))
          {
              $total = "".$result2[0].",".$result2[1].",".$result2[2]."&lt;br/&gt;"; 
              echo json_encode($total);
          }       
      }
  ?&gt;
  </code></pre>
  
  <p>The output for far for the above code as below </p>
  
  <pre><code>"A001","BILLY","email1@mail.com"
  "A002","JOHN","email2@mail.com"
  "A003","SALLY","email3@mail.com"
  </code></pre>
  
  <p><strong>fetch.php</strong></p>
  
  <pre><code>&lt;?php
      include_once('conn.php');
  
      $arr        = array();
      $query      = "SELECT * FROM TABLE "; 
      $stmt       = sqlsrv_prepare($conn, $query);
      $result     = sqlsrv_execute($stmt);
      $row        = sqlsrv_fetch_array($stmt);
  
      $array  = array();
      while( $self = sqlsrv_fetch_array( $stmt)) { 
  
          $array2 = array();
          $array2[]= $self['ID'];  
          $array2[]= $self['NAME'];  
          $array2[]= $self['EMAIL'];  
  
          $array[] =  $array2;
      }
      echo json_encode($array);
  ?&gt;
  </code></pre>
  
  <p>My goal is to change it into JSON as below. I'm missing the bracket and the coma. </p>
  
  <pre><code>[
      ["A001","BILLY","email1@mail.com"],
      ["A002","JOHN","email2@mail.com"],
      ["A003","SALLY","email3@mail.com"]
  ]
  </code></pre>
  
  <p>Appreciate if someone can help me to fix this issue. Thanks. </p>