Re: Retrieving array_keys from $_POST
| From: | Daniel J. Rychlik | Date: | Fri, 23 May 2003 13:59:20 +0000 |
| Subject: | Re: Retrieving array_keys from $_POST | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148777@lists.php.net to get a copy of this message | ||
I went home last night and laid in the bead with my trust lappie, and I
wrote a very similiar snipit just like you wrote, I love PHP. Coming from a
harden perl background, this is just incredible. What makes this so cool,
is the php program doesnt care if you add more fields to your form, it just
gets them and from their you can process the information and store them, or
whatever...
Do you think its a good idea to use SQL statements in an array ? I was
thinking of creating an array with all the SQL statements that I would need
and just calling the elements. That way it makes the code more uniform and
easy to update if needed. Rather than editing multiple lines of code, you
basically edit one array...
Thanks so much for you help!
-Dan
----- Original Message -----
From: "John W. Holmes" <holmes072000@charter.net>
To: "'Daniel J. Rychlik'" <drychlik@tcsconsult.com>;
<php-general@lists.php.net>
Sent: Thursday, May 22, 2003 7:40 PM
Subject: RE: [PHP] Retrieving array_keys from $_POST
> > Hmmm, so if I
> >
> > array_keys($_POST);
> > print (array_keys ($_POST);
> >
> > This makes it so much easier then beating a dead drum with many print
> > statements or whatever.
>
> Well, not quite. Remember, array_keys() returns another array, so you
> have to loop through it:
>
> $keys = array_keys($_POST);
> foreach($keys as $key)
> { echo "Key: $key<br />"; }
>
> of course, you could always do the same thing with just $_POST
>
> foeach($_POST as $key=>$value)
> { echo "Key: $key<br />Value of $key: $value<br />"; }
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>