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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:06:40+00:00 2026-06-05T06:06:40+00:00

I have an HTML Form that contains 20 sets of fields. Here are 2

  • 0

I have an HTML Form that contains 20 sets of fields. Here are 2 for an example:

<input type="text" class="auto-clear" id="p1weight" name="p1weight" value=""  />     
<input type="text" class="auto-clear" id="p1length" name="p1length" value="" />     
<input type="text" class="auto-clear" id="p1width" name="p1width" value="" />    
<input type="text" class="auto-clear" id="p1height" name="p1height" value="" />    

<input type="text" class="auto-clear" id="p2weight" name="p2weight" value="" />    
<input type="text" class="auto-clear" id="p2length" name="p2length"  value="" />     
<input type="text" class="auto-clear" id="p2width" name="p2width" value="" />    
<input type="text" class="auto-clear" id="p2height" name="p2height" value="" /> 

I am using the following PHP code to generate a string ($all) to store the field values:

foreach( range( 1, 20) as $i)
    {
        // Create an array that stores all of the values for the current number
        $values = array( 
            'p' . $i . 'weight' => $_POST['p' . $i . 'weight'],
            'p' . $i . 'length' => $_POST['p' . $i . 'length'], 
            'p' . $i . 'width' => $_POST['p' . $i . 'width'], 
            'p' . $i . 'height' => $_POST['p' . $i . 'height'] 
        );

        $all .= implode( '|', $values) . "\n\n";
    }

If my input for the 2 sets of fields is 1, 2, 3 & 4, this gives my $all value as: 1|2|3|4 1|2|3|4.

However, I would like to customise this more. Ultimately, I would like my $all to be:

Item1: Weight (kg):1 Length (cm): 2 Width (cm): 3 Height (cm): 4
Item2: Weight (kg):1 Length (cm): 2 Width (cm): 3 Height (cm): 4

How do I update my PHP above to achieve this?

Many thanks for any pointers.

  • 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-05T06:06:41+00:00Added an answer on June 5, 2026 at 6:06 am
    foreach( range( 1, 20) as $i)
            {
    
                $all .= "Item".$i.": Weight (kg):".$_POST['p' . $i . 'weight']." Length (cm): ".$_POST['p' . $i . 'length']." Width (cm): ".$_POST['p' . $i . 'width']." Height (cm): ".$_POST['p' . $i . 'height']."\n";
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that contains an html file browse button ( <input type=file
I have a HTML form that contains text fields, checkboxes, radiobuttons and a submit
In my HTML code, I have a form tag that contains two input boxes,
I have an HTML form that needs multiple submit buttons, like this: <input type=submit
I have 2 sets of 4 input fields in my HTML Form. I expect
I have a content submission form that contains multiple fields for input, all of
I'm trying to create a form that contains these multidimensional arrays: <input type=text name=cost[1][desc]>
I have an asp.net form that contains some html, 2 controls a calendar from
I have a web site that contains an HTML form, in this form I
I have a HTML form that has certain fields which i am opening inside

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.