Including an array inside PHP JSON -


i have created json in php follows

$result=mysqli_query($mysqli,"select * service_provide personal_id='".$personal_id."'") or die(mysqli_error($mysqli);     $row = mysqli_fetch_assoc($result); while($row = mysqli_fetch_assoc($result))  {      $data[] = array(     ' fname'   => $row['fname'],          ' email_id'   => $row['email_id'],        ' phone_number'   => $row['phone_number'],       ' state'   => $row['state'],       ' city'   => $row['city'],       ' main_id'   => $row['main_id'],       ' sub_id'   => $row['sub_id'],       ' service_id'   => $row['service_id'],       'portfolio1'  => $row['portfolio1'],       'portfolio2'  => $row['portfolio2'],       'portfolio3'  => $row['portfolio3'],   );       }       $json = json_encode($data);       echo  $json; 

now have array in php want include above json. array follows.

      $service_title=array(); $result5=mysqli_query($mysqli,"select * request_submission       req_personal_id='".$req."'") or die(mysqli_error($mysqli);        while($row5 = mysqli_fetch_assoc($result5))      {         $service_title[]=$row5["service_title"];       } 

how in insert above array php json mentioned above?

you have 2 array. 1. $data , 2. $service_title.

so can use array_merge() php function , convert new array in json.

something this.

$result = array_merge($data, $service_title); $json = json_encode($result); echo  $json;