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.
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.
As simple as that
print_r($_POST);
print_r — Prints human-readable information about a variable
$_POST
is an associative array. Use array_keys
to get the keys of the array.
$names = array_keys($_POST);
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);