$_POST & Arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

$_POST & Arrays

Post by evilcoder »

hey guys, maybe you can give me a hand with this concept.

I have a form with 3 Fields (the names of the fields are unknown as they are user defined).

Now when a user enters the details for this form, the script converts, using a foreach, the $_POST's into an array as $field=>value, so the array would look like this:

"(the field name)" => "(The Value of that field)" ,
etc etc etc

Is this clear, and can it be done. Using _POST to create an array.

What i'm truely aiming at is having a script that processes form completely autonomously and without prior Formname configurations.

Thanks.
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

refresh.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

straight from the manual

Code: Select all

while (list ($key, $val) = each ($HTTP_POST_VARS)) {
echo "$key => $val<br>";
}
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Also:

Code: Select all

foreach($_POST as $key => $val) {
   print $key . " => " . $val;
}
-Nay
Post Reply