如何在codeigniter中将数组(下面)从视图传递到控制器
Array
(
[0] => Array
(
[PersonalID] => 1111111111111
[EmployeeSalary] => 20000
[EmployeeContrib] => 750
)
[1] => Array
(
[PersonalID] => 2222222222222
[EmployeeSalary] => 10000
[EmployeeContrib] => 500
)
)
答案 0 :(得分:0)
如果你真的想将数据从视图传递到控制器那么, 首先将您的数组转换为json字符串$ jsonString = json_encode($ data),将该字符串存储在隐藏的表单字段中并将该值发布到控制器中,在控制器中使用json_decode($ jsonString)解码json,它将给出数组。
$data = array(
0 => array(
'PersonalID' => '1111111111111',
'EmployeeSalary' => '20000',
'EmployeeContrib' => '750'
),
1 => array(
'PersonalID' => '1111111111111',
'EmployeeSalary' => '20000',
'EmployeeContrib' => '750'
)
);
$jsonString= json_encode($data) ;
控制器中的
$array=json_decode($jsonString);
print_r($array);