Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 761255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:48:58+00:00 2026-05-14T15:48:58+00:00

Each div with the class row is added upon request from the user, to

  • 0

Each div with the class “row” is added upon request from the user, to be able to add multiple items at once. So now is the question how I’ll collect all the forms in to an array that PHP can read (like JSON for instance). I’ll guess that there’s already some easy and effective way of doing this?

<div class="container">
    <div class="row">
        <input type="text" name="value1" id="textfield" />
        <input type="text" name="value2" id="textfield" />
        <input type="text" name="value3" id="textfield" />
    </div>

</div>

Here’s what I would like to achieve out of the shown example:

array( 
    array ('value1' => '',
           'value2' => '',
           'value3' => '')
);

Thanks!

Update:
The form will be handled with PHP and it would be super to be able to do something like a foreach loop on the specific container-div content.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:48:58+00:00Added an answer on May 14, 2026 at 3:48 pm

    Give each ‘group’ of inputs the same name, then add square brackets to the end

    <div class="container">
        <div class="row">
            <input type="text" name="value1[]" id="textfield" />
            <input type="text" name="value2[]" id="textfield" />
            <input type="text" name="value3[]" id="textfield" />
        </div>
        <div class="row">
            <input type="text" name="value1[]" id="textfield" />
            <input type="text" name="value2[]" id="textfield" />
            <input type="text" name="value3[]" id="textfield" />
        </div>
    </div>
    

    When you post the form, your php $_POST variable will then contain arrays for value1, value2 and value2:

    var_dump($_POST); // array('value1' = array(...
    

    You can then iterate through to ‘regroup’ the rows within PHP (but first, i’d change the field names to field1 etc rather than value1):

    $rows = array(); // set up an empty array to hold your rows
    
    // loop through each POST var
    foreach($_POST AS $key=>$field) {
        if(is_array($field)) {
            foreach($field AS $rowIndex=>$fieldValue) {
                $rows[$rowIndex][$field] = $fieldValue; // put the value in a the array by row, field
            }
        }
    }
    
    var_dump($rows);
    

    This would give:

    array(
        [0] => array(
            'field1' => 'value1',
            'field2' => 'value2',
            'field3' => 'value3'
        ),
        [1] => array(
            'field1' => 'value1',
            'field2' => 'value2',
            'field3' => 'value3'
        ),
        ...
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple notes with class=.note and unique id each inside a div. On
I have displayed a row of items with same div class name but different
for example I have the following: I want to go through each div class
I have 8 divs. Each div has the class 'pre-loader'. In addition to thas
I have multiple DIVs with unique IDs. Each DIV onclick slides down and shows
In the following code, I have a div around each row in a table
I'm trying to add a div to a row of content with the click
I have a div with span4. when I add class with padding to that
I have a table with multiple rows, with each row having a button within
I have dynamic form like: <form id=formaa> <div class=row> <input type=text name=item class=item></input> <input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.