tags:

views:

64

answers:

3

How to grab all variables in a post (PHP)? I don't want to deal with $_POST['var1']; $_POST['var2']; $_POST['var3']; ... I want to echo all of them in one shot.

+3  A: 

Use:

var_dump($_POST);
Fernando
+2  A: 
echo '<pre>'; 
print_r($_POST); 
echo '</pre>';
Russell Dias
+5  A: 

If you really just want to print them, you could do something like:

print_r($_POST);

Alternatively, you could interact with them individually doing something like:

foreach ($_POST as $key => $value) {
    //do something
    echo $key . ' has the value of ' . $value;
}

but whatever you do.. please filter the input. SQL Injection gives everyone sleepless nights.

CaseySoftware
Or XSS. This sentence is here to make the comment greater than 15 characters.
icktoofay
ok, i was looking for $results = print_r($b, true), thanks
ilhan