Re: Variable Variable Array

From: Date: Thu, 10 Mar 2005 19:19:02 +0000
Subject: Re: Variable Variable Array
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-38859@lists.php.net to get a copy of this message
Ryan Jameson (USA) wrote:
Hi Folks, I've been using "variable variables" for years with PHP. $var = "myVarName"; $$var = "Some Val"; echo $myVarName; //outputs "Some Val" [snip]
Example: $var['first']='bob'; $var['second']='frank'; $varName = "myVarName"; $$varName = $var; echo $$varName['second']; //should output "frank" but doesn't. :-\ <----------------------------- echo $var['second']; //should output "frank" works fine.
Try adding $frank = 'woopsie!'; to the top of your script and running it. ----- echo ${$VarName}['second']; is what you want - you want to be very clear what order these things need to be analyzed in, especially when dealing with arrays and the likes. Cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.

« previous php.db (#38859) next »