Php – How to get the key values from $_POST

arraysphp

echo $_POST["name"]; //returns the value a user typed into the "name" field

I would like to be able to also return the text of the key. In this example, I want to return the text "name". Can I do this?

Best Solution

$_POST is just a normal associative array so you can also loop over the entire thing like this:

foreach($_POST as $key=>$value)
{
  echo "$key=$value";
}