RE: [PHP] array_push but with key, value pairs
| From: | Peter Houchin | Date: | Tue, 17 Apr 2001 05:48:40 +0000 |
| Subject: | RE: [PHP] array_push but with key, value pairs | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48897@lists.php.net to get a copy of this message | ||
what about if you assign the key to = the id (if in a data base)?
maybe like
while (list ($key, $val) = each ($id)) {
if ( $key != "Submit" ) {
> array_push($input, $val);
> }
>
> }
-----Original Message-----
From: Joseph Blythe [mailto:joe.blythe@binarylogic.com.au]
Sent: Tuesday, April 17, 2001 3:40 PM
To: Peter Houchin
Cc: php-general@lists.php.net
Subject: Re: [PHP] array_push but with key, value pairs
Peter Houchin wrote:
> maybe tring this ...
> $input = array();
>
> reset ($HTTP_POST_VARS);
>
> while ( list($key, $val) = each($HTTP_POST_VARS) ) {
> if ( $key != "Submit" ) {
> array_push($input, $val);
> }
>
> }
Hmm, as far as I can see this will just reset the internal pointer back
to the start of the HTTP_POST_VAR array, I suppose this should be done
in case I have called 'each' on the array before, but it does not answer
my question being: I want to push the key and value into an array not
just the value. I basically need array_push functionality but with the
ablility to use your own index values.
I hope this is more clear.
Regards
Joseph