Re: Using $$ to access a variable

From: Date: Mon, 23 Jul 2001 19:04:44 +0000
Subject: Re: Using $$ to access a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59265@lists.php.net to get a copy of this message
I'm not sure that your construct will work; however, you could always do echo $HTTP_POST_VARS[$table_array[$iCnt][0]]; in place of 'echo $$var' or $var = 'HTTP_POST_VARS'; echo ${$var}[$table_array[$iCnt][0]]; When using variable variables, the array index - here, 'ld_val' might not be interpreted correctly; I'm guessing that PHP is looking for a variable named 'HTTP_POST_VARS["ld_val"]', not an element of the HTTP_POST_VARS array. More info is at http://www.php.net/manual/en/language.variables.variable.php On the other hand, are you absolutely sure that something (other than whitespace) is actually IN $HTTP_POST_VARS['ld_val'] ?? - steve At 5:36 PM +0000 7/23/01, usenet5@hoovernebrig.com wrote:
Please forgive my probably newbie question... I am cycling thru my database using a SQL describe statement and then am getting values from a form based upon the field name I find. This is working up 'til I try to read the form data. I have defined a variable like this: $var = $prefix.$table_array[$iCnt][0].$postfix; If I echo $var the printed result is: HTTP_POST_VARS["Id_val"] This is perfect because I want to access a field on the submitted form named "Id_val", but when I try echoing with a $$ like this: echo $$var I get nothing. I was under the impression that I could access my variable this way. Am I missing something basic here?? Thanks! Mark
-- +------ Factoid: Of the 100 largest economies in the world, 51 are ------+ | Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +--- corporations ------ http://www.ips-dc.org/reports/top200text.htm ---+

« previous php.general (#59265) next »