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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:51:49+00:00 2026-05-24T23:51:49+00:00

Possible Duplicate: PHP $_POST print variable name along with value I have a form

  • 0

Possible Duplicate:
PHP $_POST print variable name along with value

I have a form (whatever number of fields).. this form will send $_POST data.. I want to return every $_POST variable value and name.

I wanna do soemthing like this :

foreach($_POST as $field){
    //****some code*****//
}

in a way that will display the fields and values like this:

name : Simo Taqi
email : example@ymail.com

in other words :

if I have a post variable : $_POST[‘city’]=’las vegas’

I want to know how to get the name of the variable : ‘city’.

  • 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-24T23:51:50+00:00Added an answer on May 24, 2026 at 11:51 pm

    $_POST is populated as an associative array, so you can just do this:

    foreach ($_POST as $name => $val)
    {
         echo htmlspecialchars($name . ': ' . $val) . "\n";
    }
    

    Additionally, if you’re just interested in the field names, you can use array_keys($_POST); to return an array of all the keys used in $_POST. You can use those keys to reference values in $_POST.

    foreach (array_keys($_POST) as $field)
    {
        echo $_POST[$field];
    }
    
    • foreach documentation
    • array_keys documentation
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a
Possible Duplicate: Thanking visitor by name after contact form submision I have the line
Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be
Possible Duplicate: PHP ToString() equivalent I get this error: Catchable fatal error: Object of
Possible Duplicate: Reference: Comparing PHP's print and echo Is there any major and fundamental
Possible Duplicate: Pass a PHP string to a Javascript variable (and escape newlines) I
Possible Duplicate: PHP Regular express to remove <h1> tags (and their content) I have
Possible Duplicate: PHP: How To Disable Dangerous Functions Hi, this is my situation: I
Possible Duplicate: PHP - How to split a paragraph into sentences. I have a
Possible Duplicate: Why PHP variables start with a $ sign symbol? I have looked

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.