Insert keys into an array using variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux