How can I refer to all variables of a POST string using PHP ?
$_POST['var0']
$_POST['var1']
what if I don't know the names var0, var1.. and how many they are ?
thanks
how to handle multiple variables
Moderator: General Moderators
Re: how to handle multiple variables
Code: Select all
foreach($_POST as $k => $v) { print("['$k'] = $v, "); }Re: how to handle multiple variables
thanks, I still have one question:
if this is my POST:
why do my output is inverted ? (dropDown2 is before dropDown1)
if this is my POST:
and this is my code:dropDown0=1&dropDown1=1&dropDown2=1
Code: Select all
$fname = "form.xml";
$fhandle = fopen($fname,"w");
foreach($_POST as $entry => $value) {
if ($entry!="dataFormat") fwrite($fhandle, "<$entry> $value </$entry> \n");
}
fclose($fhandle);
why do my output is inverted ? (dropDown2 is before dropDown1)
Code: Select all
<dropDown0> 1 </dropDown0>
<dropDown2> 1 </dropDown2>
<dropDown1> 3 </dropDown1>
Re: how to handle multiple variables
No clue, probably depends on your webserver and PHP settings. But it's easily taken care of with
See also the manual.
Code: Select all
ksort($_POST);