Hi buddys.

i put these HTML in my form:

<input type='checkbox' name='test[two][]' value='ITEM1'  />
<input type='checkbox' name='test[two][]' value='ITEM2'  />
<input type='checkbox' name='test[two][]' value='ITEM3'  />
<input type='checkbox' name='test[two][]' value='ITEM4'  />

I think if i submit it, it will show this is correct:

    [test] => Array
        (
            [two] => Array (
                        [0] => 'ITEM1'
                        [1] => 'ITEM3'
                )
        )

but i submit this form, then i used print_r() to show the array of $_POST,
it showed:

    [test] => Array
        (
            [two] => Array
        )

It's just show a string that is 'Array'.

Why?

Thank you very much.

    because the child array is a numeric indexed array starting at "0" as opposed to an associative array.

      Thank you YAOMK, and i tried this:

      <input type='checkbox' name='test[two][X1]' value='ITEM1'  />
      <input type='checkbox' name='test[two][X2]' value='ITEM2'  />
      <input type='checkbox' name='test[two][X3]' value='ITEM3'  />
      <input type='checkbox' name='test[two][X4]' value='ITEM4'  />
      

      but it still doesn't work...

        this is what your first example would give you if you were to print_r($_POST['test']):

        Array ( [two] => Array ( [0] => ITEM4 ) )

        what is wrong with it?

        test.php

        <form method="post" action="test.php">
        <input type='checkbox' name='test[two][]' value='ITEM4'  /> 
        <input type="submit">
        </form>
        <?php
        print_r($_POST['test']);
        ?>

          Oh, Sorry ,

          I found the reason, because of it filtered by a framework, i got the $_POST is not original one.

          Thank you for you help!

            Write a Reply...