views:

111

answers:

7

I have problem with getting the content. I don't know the names of the post variables so I can't do this using

 = $_Post['name']

because I don't know the "name". I want to catch all of the variables send by POST method. How can I get keys of the $_Post[] array and the values related with them?

+6  A: 

Standard for-each:

foreach ($_POST as $key => $value)
{
  // ... Do what you want with $key and $value
}
Matthew Flaschen
+2  A: 

$_POST is just a big array:

while(list($keys,$vars) = each($_POST)){ // do something. }
Aaron Harun
A: 

Just use a for each loop

foreach($_POST as $key => $value){
   echo "$key = $value";
}
Adam Pope
+1  A: 

for some quick debugging, you can also use

print_r ($_POST)
wag2639
A: 

To get the keys:

array_keys($_POST);

DjDarkman
A: 

Besides print_r($_POST); you could also use var_dump($_POST);, but most logical solution as mentioned earlier is foreach loop.

Eugene
A: 

basically post request will be mapped to array. for debuging you can call

var_dump($_POST);

this code will list all array within post array.

Jeg Bagus