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 8498517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:25:29+00:00 2026-06-11T00:25:29+00:00

I have: <form action=save.php method=POST> <input type=text name=test[one][] value=a><input type=text name=test[two][] value=a> <br />

  • 0

I have:

<form action="save.php" method="POST">
<input type="text" name="test[one][]" value="a"><input type="text" name="test[two][]"  value="a"> <br />
<input type="text" name="test[one][]" value="s"><input type="text" name="test[two][]"  value="s"><br />
<input type="text" name="test[one][]"  value="d"><input type="text" name="test[two][]"  value="d"><br />
<input type="text" name="test[one][]"  value="f"><input type="text" name="test[two][]"  value="f"><br />
<input type="text" name="test[one][]"  value="g"><input type="text" name="test[two][]"  value="g"><br />

<input type="submit">
</form>

In database are:

 Table:
 id | one | two

in PHP i would like make:

if($_POST){
   foreach($_POST['test'] as $post){
          $new = new Table();
          $new->setOne($post['one']);
          $new->setTwo($post['two']);
          $new->save(); 
   }
}

But this not working… I can’t use POST for index ‘one’ and ‘two’ – i must use two loop foreach. Is possible to make with one foreach or foreach in foreach?

print_r($_POST) return me:

[test] => Array ( [one] => Array ( [0] => a [1] => s [2] => d [3] => f [4] => g ) [two] => Array ( [0] => a [1] => s [2] => d [3] => f [4] => g ) ) ) 
  • 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-06-11T00:25:31+00:00Added an answer on June 11, 2026 at 12:25 am

    I would go this way:

    if (!empty($_POST)) {
      // now $_POST['test'] is array('one' => array(), 'two' => array()
      for ($i = 0, $c = count($_POST['test']['one']); $i < $c; ++$i) {
        $new = new Table();
        $new->setOne($_POST['test']['one'][$i]);
        $new->setTwo($_POST['test']['two'][$i]);
        $new->save();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form: <form method='post' action='script.php'> <textarea id='main' name='text'></textarea> <input type='hidden' name='id' value='1'> <input
I have this form: <form action= method=post> <label for=color>Color:</label> <input type=text style=width: 195px; name=color
I have this markup. <form action='xxx.php' method='post'> <table> <tr> <th>Branch Id</th> <td><input id=branchId type=text
I have simple form: <form action=add.php method=post > <input name=name maxlength=30/><br/> <textarea cols=80 name=description
this is my form <form name=thumbnail action=<?php echo $_SERVER[PHP_SELF];?>?complete=true method=post> <input type=hidden name=x1 value=
I have defined text fields as follows: <form name=form1 method=post action=save_banners.php onsubmit=return check_form();> <input
I have a form with the following HTML below: <form id=course_edit_form name=course_form action=/courses/save method=post>
I have a page with a form like so: <form method=POST action=scripts/save-settings2.php> <div id=posts>
I have the existing code: <form action=page.php?id=<?= $_GET['id'] ?> method=post> <fieldset> <p id=edit_name><label for=name>Page
<form action=form.php id=form> <input type=text name=name_1><input type=text name=city_1><input type=text name=country_1> <input type=text name=name_2><input type=text

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.