text: Q:
  
  return data from web service in one json string
  
  i want to return data from a web services with php in one group json container. my below script gives me each of the data seperated like this
  {"No":"01","Name":"JOSEPH"}{"No":"02","Name":"AMINU"}
  
  But i wan it to return like this
  [{"No":"01","Name":"JOSEPH","No":"02","Name":"AMINU"}]
  
  below is my script
  try{
      $service = new NTLMSoapClient($pageURL);
       $params = array('filter' => array( 
                          array('Field' => 'District_Name',  'Criteria' => '')
                                         ), 
                       'setSize' => 2); //setSize =0 will return all rows - Can cause performance issue with large results set!
       $result = $service->ReadMultiple($params); 
       $resultSet = $result->ReadMultiple_Result->customer;
  
      if (is_array($resultSet)) { 
          foreach($resultSet as $item) { 
              $data=array('No' => $item->No,'Name' => $item->Name);
              echo json_encode($data);
              } 
          } 
          else { 
  
              echo json_encode('record not found');
          }
      }
  catch (Exception $e) {
      echo "<hr><b>ERROR: SoapException:</b> [".$e."]<hr>";
      echo "<pre>".htmlentities(print_r($service->__getLastRequest(),1))."</pre>";
  }
  
  A:
  
  Try you foreach with this.
  try{
      $service = new NTLMSoapClient($pageURL);
       $params = array('filter' => array( 
                          array('Field' => 'District_Name',  'Criteria' => '')
                                         ), 
                       'setSize' => 2); //setSize =0 will return all rows - Can cause performance issue with large results set!
       $result = $service->ReadMultiple($params); 
       $resultSet = $result->ReadMultiple_Result->customer;
  
      if (is_array($resultSet)) { 
         $jsonArray = [];
         foreach($resultSet as $item) { 
         $data = array('No' => $item->No,'Name' => $item->Name);
         $jsonArray = array_merge($jsonArray, $data);
      } 
      echo json_encode($jsonArray);
  
          } 
          else { 
  
              echo json_encode('record not found');
          }
      }
  catch (Exception $e) {
      echo "<hr><b>ERROR: SoapException:</b> [".$e."]<hr>";
      echo "<pre>".htmlentities(print_r($service->__getLastRequest(),1))."</pre>";
  }
  
  