您好我是codeigniter的新手。我正在使用codeIgniter构建一个Web服务。我有一个json格式,如下所示
{
"pk_mobilenumber": 9711954265,
"first_name": "utpal",
"last_name":"sharma",
"password":"Spaneos",
"email_address":"utpalsharma@spaneos.com",
"address":[
{
"area": "abc",
"zipcode": "12344"
}
]
}
我想分别获取地址数组的值。我有剩余的值,因为它是一个post方法。我的下面的post方法给了我除地址数组以外的所有值,请帮我获取地址数组值。
function addUser_post(){
$pk_mobilenumber = $this->post('pk_mobilenumber');
$first_name = $this->post('first_name');
$last_name = $this->post('last_name');
$password = $this->post('password');
//$city = $this->address->post('city');
$address[] = $this->post('address');
$area=$this->post("address['area']");
//$zipcode=$this->post('zipcode');
//$country=$this->address->post('country');
$email_address = $this->post('email_address');
//$data = json_decode($address);
//echo $address;
//echo $data['area'];
//echo $zipcode;
//$address = $this->post('address',"[]");
// $address1 = explode(",", $address);
//echo $address1;
echo $area;
//echo $zipcode;
$this->load->model('register_model');
//echo "register";
$data = $this->register_model->addUser($pk_mobilenumber,$first_name,$last_name,$password,$email_address);
if($data){
$this->response("Registration is successful", 201);
}else{
$this->response("User already exists. Please try with different Mobile number", 400);
}
}