Re: Grabbing ALL $_POST var at once.
| From: | Philip Olson | Date: | Mon, 06 May 2002 19:53:12 +0000 |
| Subject: | Re: Grabbing ALL $_POST var at once. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96316@lists.php.net to get a copy of this message | ||
As you know, $_POST exists. You can also assign
groups of names to an array through your HTML form
like so:
<input type="text" name="bar[name]">
<input type="text" name="bar[doh]">
...
And then play with them, for example:
extract($_POST['bar']);
print "I say $name and $doh";
extract($_POST['bar'], EXTR_PREFIX_ALL, 'bar');
print "I say $bar_name and $bar_doh";
extract() is a pretty cool function with many
options, read about extract here:
http://www.php.net/extract
And as already stated by others,
import_request_variables() and $_REQUEST exist too.
Regards,
Philip Olson
On Mon, 6 May 2002, 1LT John W. Holmes wrote:
> extract() wouldn't do you any good here, you'd still have to use echo $one,
> echo $two, etc...so what are you gaining?
>
> If you just want the values displayed, use the foreach() method someone
> already posted. You can use implode() to combine the whole array in to a
> single string...if you need something more than that, let us know. With that
> many elements, maybe it's time to rethink your layout or naming conventions.
>
> ---John Holmes...
>
> ----- Original Message -----
> From: "David J Jackson" <david.j.jackson@pickledbeans.com>
> To: "1LT John W. Holmes" <holmes072000@charter.net>
> Cc: <php-general@lists.php.net>
> Sent: Monday, May 06, 2002 3:07 PM
> Subject: Re: [PHP] Grabbing ALL $_POST var at once.
>
>
> > John ---
> > Thanks for your reply, but let me rephase the question.
> > Let say I have a form with 50 fields on it do I have to:
> >
> > echo $_POST['one']
> > ....
> > .....
> > .....
> > echo $POST['fifty']
> >
> >
> > Or should I, could I use extract()?
> >
> > Thanks in advance,
> > David
> >
> > p.s I said it was UGLY :)
> >
> >
> > > ?>
> > >
> > > If that's too hard to understand, use extract().
> > >
> > > ---John Holmes...
> > >
> >
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>