-1

Is there a way to get the names of the form fields from $_POST ?

I know I can get the values with $_POST['foo'], but how do I get the list of names (not sure what they are called).

Any help is great.

Sumner Evans
  • 8,951
  • 5
  • 30
  • 47
BDMan32
  • 53
  • 1
  • 6

3 Answers3

0

As simple as that

print_r($_POST);

print_r — Prints human-readable information about a variable

http://php.net/manual/en/function.print-r.php

ihsan
  • 2,279
  • 20
  • 36
0

$_POST is an associative array. Use array_keys to get the keys of the array.

$names = array_keys($_POST);
Barmar
  • 741,623
  • 53
  • 500
  • 612
0

An array consists of array key and value.

$array = array('color1' => 'red','color2' => 'blue', 'color3' => 'green');

to get the key values use

$keys = array_keys($array);
print_r($keys);
aiswarya
  • 567
  • 6
  • 8