try this..

<?

$exception = array("var1","var2","var3") // these are the 
variables I don't
want to catch
$array = array(); // the array to put the variables into

while (list($key,$value) = each($_POST)) {
        if (in_array($key,$exception)){
                $$key = $value;
        }else{
            $array = array_merge($array, array($key=>$value));
      }           
}

?>

$stack = array_merge($stack, array("one"=>"test"));

Aaron N Wagner
WagnerWebDesign.net



> -----Original Message-----
> From: Rafael Soares [mailto:[EMAIL PROTECTED]
> Sent: November 22, 2004 10:58
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Insert keys into an array using variables
> 
> 
> Hello!
> 
> I have a script that gets some _POST variables (all, except some ones
> specified in an array) and puts into another array, to use 
> them in an e-mail
> message later.
> 
> But the script needs to catch ANY vars, like I don't know 
> which vars will be
> sent in _POST.
> 
> This script will show it better:
> 
> <?
> 
> $exception = array("var1","var2","var3") // these are the 
> variables I don't
> want to catch
> $array = array(); // the array to put the variables into
> 
> while (list($key,$value) = each($_POST)) {
>       if (in_array($key,$exception))
>               $$key = $value;
>       else // here is the problem... How can I use the 
> variable $key to
> add keys into the array??
>               $array[$key] = $value; // I also tried $array[&$key] =
> $value but it didn't work
> }
> 
> ?>
> 
> Later in the message, I'll use this loop:
> 
> <?
> 
> while (list($field,$data) = each($array)){
>       $msg .= "- " . $field . ": " . $data . "\n";
> }
> 
> ?>
> 
> I can't realize how I can do this... 
> 
> Thanks in advance.
> 
> Rafael Soares - AgênciaM
> Fone:  +55 11 4616-1394
>  
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to