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

  • Home
  • SEARCH
  • 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 7880517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:09:46+00:00 2026-06-03T04:09:46+00:00

I have a form in which i use two dimensional array for field names.The

  • 0

I have a form in which i use two dimensional array for field names.The fields names are below

myform[message][]

myform[name][]

myform[add][]

it means there are three arrays.Every array has arrays inside it.when i var_dump my form after putting values and submitting it.I get the below structure of 2d array.

array
  ''message'' => 
    array
      0 => string 'adnan' (length=5)
      1 => string 'khan' (length=4)
      2 => string 'salman' (length=6)
  ''name'' => 
    array
      0 => string 'khan' (length=4)
      1 => string 'kamran' (length=6)
      2 => string 'khan' (length=4)
  ''add'' => 
    array
      0 => string 'asad' (length=4)
      1 => string 'khan' (length=4)
      2 => string 'abrar' (length=5)

As you can see the associative array.I want to store the values of message,name and add in a database table having three fields to store the values of message,name and add fields in a single query by using some loop like foreach.
when i use this code

foreach($_REQUEST['myform'] as $val)
 foreach($val as $v)

  {
    echo $v;
  }

I get all the values of the array.But i think i am unable to save it to database table

as all the values are in the variable $v.How to store message in a message field,name in name field and add in an add field in a table of a db.

please advice.Thanks

  • 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-03T04:09:47+00:00Added an answer on June 3, 2026 at 4:09 am
    foreach($_REQUEST['myform'] as $field=>$val)
     // $field is the key
     foreach($val as $v)
    
      {
        echo $field . ' ' . $v;
      }
    

    That will give you the field name to work with. I assume you know how to insert entries into a database already.

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

Sidebar

Related Questions

I have two identically-sized numpy.array objects (both one-dimensional), one of which contains a list
I have a basic html form which I want to use with two submit
I have a form input consisting of two radiobuttons, for one name, as below:
I have a form which users can add controls to and when they right
I have to send a two-dimensional JavaScript Array to a PHP page. Indeed, I'm
I have a specific field in a form which needs to have a custom
I have a global form which I want to use the same form every
I have a template page expecting two forms. If I just use one form,
The idea is that I have a form with two editable fields, data is
I have one form which need to submit data into two different tables in

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.