hello I made a post method with the API, I want to make a response like the following what can?
{
"status": 200,
"error": false,
"data": [
{
"id_kab": "56",
"id_prov": "1",
"kd_kab": "CGK10000"
}
]
}
what I did through POSTMAN now results like this
{
"id_kab": "56",
"id_prov": "1",
"kd_kab": "CGK10000"
}
this my code insert to database
public function submit_post() {
$data = array(
'id_kab' => $this->input->post('id_kab'),
'id_prov' => $this->input->post('id_prov'),
'kd_kab' => $this->input->post('kd_kab')
);
$insert = $this->db->insert('service', $data);
if ($insert) {
$arr=array(
'status' => 200,
'message' => 'Success'
);
header('Content-Type: application/json');
echo json_encode($arr,TRUE);
} else {
$this->response(array('status' => 'fail', 502));
}
}
how to change the response? thank you
optionsparameter tojson_encode(). php.net/manual/en/function.json-encode.php