Re: How can I access the value in a variable whos name is in a string

From: Date: Sat, 18 May 2002 15:14:57 +0000
Subject: Re: How can I access the value in a variable whos name is in a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98263@lists.php.net to get a copy of this message
simple.. try this: echo eval($variablename); then again why are you eval()ing at all?? why can't you do this: $var1="var2"; $$var1=13; echo $var2; //or perhaps even better: //echo $$var1; seems simple enough.. haven't tested but theory is there I think.. HTH ::::::::::::::::::::::::::::::::::::::::::: : Julien Bonastre [The-Spectrum.org CEO] : A.K.A. The_RadiX : the_radix@hotkey.net.au : ABN: 64 235 749 494 : QUT Student #: 04475739 ::::::::::::::::::::::::::::::::::::::::::: ----- Original Message ----- From: "Henry" <henry@teacake.f9.co.uk> To: <php-general@lists.php.net> Sent: Sunday, May 19, 2002 12:29 AM Subject: [PHP] How can I access the value in a variable whos name is in a string > Dear All, > > $variablename="variable"; > eval("\$".$variablename."=13;"); > echo $variable; > > This works fine!! It echoes "13"; > > But this doesn't -> > > echo eval("\"$variablename\""); > > Why?? > > > Henry > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#98263) next »