Page 1 of 1
count POST parameters [Solved]
Posted: Tue May 08, 2007 8:24 am
by sarris
Hi there,
I am calling this php script which is not called always with the same ammount of parameters. Is there a way to get all the POST parameters in an array or in a way iterate through them so i get them all every time?
Thanks
Posted: Tue May 08, 2007 8:28 am
by Grim...
I'm not entirely sure what you mean.
You can count POST parameters quite easily:
Posted: Tue May 08, 2007 8:57 am
by CoderGoblin
As for stepping through them...
Code: Select all
foreach ($_POST as $key=>$value) {
echo "POST input {$key} has a value of [{$value}]<br />";
}
the $_POST is a "Read only" array although you cannot change any values you can perform most array functions on it.
Posted: Tue May 08, 2007 9:01 am
by Grim...
CoderGoblin wrote:the $_POST is a "Read only" array although you cannot change any values you can perform most array functions on it.
This script disagrees:
Code: Select all
<?php
print "<pre>";
print_r($_POST);
$_POST['bob'] = "changed!";
print_r($_POST);
print "</pre>";
?>
<form method="post">
<input type="text" name="bob" />
</form>
Output is something like
Code: Select all
Array
(
[bob] => cake
)
Array
(
[bob] => changed!
)
Posted: Tue May 08, 2007 9:11 am
by CoderGoblin
My mistake

... Wouldn't recommend it however.
Posted: Wed May 09, 2007 7:42 am
by sarris
great,
thanks