-1

我有这个表格http://jsfiddle.net/U7Wp2/我要发布到这个 php 脚本

<?php
$all = $_POST;

echo '<pre>';
print_r($all);
echo '<pre>';

?>

我得到以下数组

<pre>Array
(
    [one] => 1
    [two] => 2
    [three] => 3
    [four] => 4
    [cr_one] => Array
        (
            [0] => aa
            [1] => ee
        )

    [cr_two] => Array
        (
            [0] => bb
            [1] => ff
        )

    [cr_three] => Array
        (
            [0] => cc
            [1] => gg
        )

    [cr_four] => Array
        (
            [0] => dd
            [1] => hh
        )

    [six] => 6
    [seven] => 7
    [eight] => 8
    [kr_one] => Array
        (
            [0] => tt
            [1] => pp
            [2] => er
        )

    [kr_two] => Array
        (
            [0] => rr
            [1] => oo
            [2] => en
        )

    [kr_three] => Array
        (
            [0] => uu
            [1] => ll
            [2] => et
        )

    [kr_four] => Array
        (
            [0] => yy
            [1] => qq
            [2] => ey
        )

    [ten] => 10
    [eleven] => 11
    [twelve] => 12
)
<pre>

为了生成数组,我使用按钮克隆了 2five crud个,使用按钮克隆了 3nine_crud个。每个克隆的表单有四个字段。生成的数组的问题是,每个克隆的表单字段都被严重拆分并且没有一起出现(字段 1 到字段4)作为一个数组。例如在这个数组中

[kr_one] => Array
    (
        [0] => tt
        [1] => pp
        [2] => er
    )

[kr_two] => Array
    (
        [0] => rr
        [1] => oo
        [2] => en
    )

[kr_three] => Array
    (
        [0] => uu
        [1] => ll
        [2] => et
    )

[kr_four] => Array
    (
        [0] => yy
        [1] => qq
        [2] => ey
    )

在这个数组中,我有三个不同的克隆项目,但它们不会显示为单个数组。我可以为单个克隆框中的字段显示为统一数组吗?

4

1 回答 1

1

如果您只想要一个数组,则必须将相同的name属性放在每个克隆的盒子上。那是name='kr[]'四个盒子。

然后在 PHP 中,如果您克隆 3 次,您将获得一个包含 12 个值的数组。像这样的东西:

[kr] => Array
(
    [0] => tt
    [1] => rr
    [2] => uu
    ....
    ....
    [11] => ey
)
于 2013-09-08T15:07:32.193 回答