2

Is it possible to create an array in an array for inputs?

So:

<input type="text" name="array[array[]]" />

Thanks.

2 Answers 2

3

A two dimensional array is an array inside an array. Many questions like this...

<input type="text" name="import[fields][0]" >
Sign up to request clarification or add additional context in comments.

Comments

0
 In HTML

    <input type="text" name="import[fields][0]" >
    <input type="text" name="import[fields][1]" >
    <input type="text" name="import[fields][2]" >
 IN PHP
    <?php
    if ( isset($_POST['submit']) )
    {
        print_r($_POST['field']); 
    }
    ?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="field[one][1]" />
<input type="text" name="field[one][2]" />
<input type="text" name="field[one][3]" />
<br /><br />
<input type="text" name="field[two][1]" />
<input type="text" name="field[two][2]" />
<input type="text" name="field[two][3]" />
<br /><br />
<input type="submit" name="submit" />
</form>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.