0

嗨,我正在使用 codeigniter 和sheepIt 克隆表单。(嵌入表单)。

我试图在提交后将数据插入数据库。

当我使用 print_r() 时,输出数据就是这种格式

Array
(
[project] => Array
    (
        [0] => Array
            (
                [module] => Design
                [features] => Array
                    (
                        [feature_0] => Array
                            (
                                [feature] => Login
                                [Hours] => 10
                            )

                        [feature_1] => Array
                            (
                                [feature] => Signup
                                [Hours] => 10
                            )

                    )

            )

        [1] => Array
            (
                [module] => Development
                [features] => Array
                    (
                        [feature_0] => Array
                            (
                                [feature] => Login
                                [Hours] => 20
                            )

                    )

            )

    )

[submit] => save
)

我也可以发布sheepIt形式的代码。

4

1 回答 1

1

回答:

$arr_data = $this->input->post();

foreach($arr_data['project'] as $prj) {
    foreach($prj as $i) {
        $arr['module'][] = module = $i['module'];
        foreach($i['features'] as $f) {
            $arr['feature'][] = $f['feature'];
            $arr['Hours'][] = $f['Hours'];
        }
    }
}
print_r($arr);

将此处理后的 $arr 数据用于存储或其他用途。

于 2013-07-17T07:25:20.037 回答