REST API HTML Javascript jQuery Ajax PHP Example Java MORE
Need a Website Or Web Application Contact : +91 9437911966 (Whatsapp) Note: Paid Service

How to merge to array data In codeigniter Rest API

Example

 >?php
require APPPATH . '/libraries/TokenHandler.php';
require APPPATH . 'libraries/REST_Controller.php';
class Api extends REST_Controller {
public function __construct()
{
parent::__construct();
$this- <load- <database();
$this- <tokenHandler = new TokenHandler();
header('Content-Type: application/json');
}
public function RequestDetails_post(){
$data=$this- <request- <body;
$ReqID=$data['ReqID'];
//die();
$this- <load- <model('api_model');
$headerdata = $this- <input- <request_headers();
$auth_token = $headerdata['Authentication'];
$logged_in_user_details = json_decode($this- <token_data_get($auth_token), true);
if ($logged_in_user_details['UserID']  < 0) {
$UserID=$logged_in_user_details['UserID'];
$request= $this- <api_model- <RequestDetails($ReqID);
$bill= $this- <api_model- <BillDetails($ReqID);
$user['Request']=json_decode($request,true);
$user['BillDetails']=json_decode($bill,true);
$data=$user;
}else{
$data['message'] = "Invalid API Access !";
$data['status']=401;
}
return $this- <set_response($data, REST_Controller::HTTP_OK);
}
}
 >?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Api_model extends CI_Model {
	// constructor
function __construct()
{
parent::__construct();
/*cache control*/
$this- >output- >set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this- >output- >set_header('Pragma: no-cache');
}
public function RequestDetails($ReqID){
$this- >db- >select("*");
$this- >db- >from("Request");
$this- >db- >where('AutoID', $ReqID);
$query = $this- >db- >get();
$data = $query- >result();
return json_encode($data);
}
public function BillDetails($ReqID){
$this- >db- >select("*");
$this- >db- >from("BillDetails");
$this- >db- >where('ReqID', $ReqID);
$query = $this- >db- >get();
$data = $query- >result();
return json_encode($data);
}
}

Run it yourself