HTTP_POST_VARS gives odd results

From: Date: Tue, 28 Nov 2000 16:40:35 +0000
Subject: HTTP_POST_VARS gives odd results
Groups: php.general 
Request: Send a blank email to php-general+get-27617@lists.php.net to get a copy of this message
I have the following code which doesn't seem to give me the results I expect. if ($testvar == "other") { $newvalue1="string1"; $newvalue2="string2"; $HTTP_POST_VARS[addr] = $newvalue1; $HTTP_POST_VARS[city] = $newvalue2; } reset($HTTP_POST_VARS); while (list($key,$value) = each($HTTP_POST_VARS)) { echo "key, value = $key, $value<Br>"; if (empty($$key) ) { do stuff; else do other stuff; } } The above while loop works perfectly without the code before it. However, when I add the code before it that changes the values of some of the elements in HTTP_POST_VARS, it no longer works. The values were changed successfully, the echo in the loop shows the correct changed values of string1 and string2 for $key,$value. However, when it gets to the if (empty) statement, it is evaluated as empty (its previous value) and do stuff is done, rather than do other stuff. The elements of HTTP_POST_VARS that were not changed still are evaluated correctly by the if empty statement; only the changed elements are evaluated incorrectly. Clearly, I am not understanding something about HTTP_POST_VARS. Can someone tell me what I am doing wrong? Janet

« previous php.general (#27617) next »