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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:39:12+00:00 2026-05-24T21:39:12+00:00

I am trying to get the data from the form I created where I

  • 0

I am trying to get the data from the form I created where I used an array to name them like:

<input type="text" name="fname[]" />
<input type="text" name="mname[]" />
<input type="text" name="lname[]" />

where the said form field are dynamically inserted or removed in the page.

On my script to get the values of the forms, I wrote something like:

$student = array(
     'fname' => '$_POST[fname]',
     'mname' => '$_POST[mname]',
     'lname' => '$_POST[lname]',
);

But when I used var_dump to see the values, each field will be indexed from zero and if it has repeating fields, it would be again be declared as another array inside an array.

What I wanted to do is to have an array with this stucture:

$student = array(
     array(
          'fname' => 'fname1',
          'mname' => 'mname1',
          'lname' => 'lname1'
     ),
     array(
          'fname' => 'fname2',
          'mname' => 'mname3',
          'lname' => 'lname2'
     )
);

I tried using a loop but I just fail again and again. Can anyone help me solve this problem?

Thank you in advance for your help.

  • 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-24T21:39:13+00:00Added an answer on May 24, 2026 at 9:39 pm
    <input type="text" name="student[]['fname']" />
    <input type="text" name="student[]['mname']" />
    <input type="text" name="student[]['lname']" />
    

    no loops necessary. Your $_POST['student'] variable will automatically be the array you wanted to achieve.

    EDIT: this isn’t achieving the desired result. It’s incrementing student for each field. adding an n value to the first set of brackets like student[n][fname] does achieve the desired result. I don’t know how the script is written to dynamically generate these three fields on the fly, but if you can figure out how to add an n value you’re golden.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way of handling trying to get data from a DataReader
I'm trying to use jQuery to get data from an ASP.NET web service (SharePoint
Im trying to get a completly data copy from a gridview, itryed clone(), tryed
I am trying to get the DB2 data provider from a 32-bit .Net application
I'm trying to get ReportViewer to display data from a BindingSource (VB.Net Winforms). I
Has anyone used jquery to take data from one form field and put it
Has anyone used javascript/ajax to take data from one form field and put it
am trying to fetch some data from a form, but i cant for some
I am trying to get some XML data with LINQ, but running into a
I'm trying to use rusage statistics in my program to get data similar to

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.