problems with variable variables...

From: Date: Sat, 13 Jul 2002 05:20:39 +0000
Subject: problems with variable variables...
Groups: php.general 
Request: Send a blank email to php-general+get-107482@lists.php.net to get a copy of this message
I'm having a huge problem with getting variable variables to work. Here's what the code looks like... // This is set from a previous array... ///////////////////////////////////////////////// $the_variablename[0] = "processors"; // Now I include a file called vars.processors.php // (which contains an array called processors[] ) ///////////////////////////////////////////////// include("vars.".$the_variablename[0].".php"); Everything works fine so far. Then i make the variable variable, and the shit happens. // I want to set a javascript array value - already // set up in the script... // So I want to retrieve a value from the included // file dynamically and create a javascript statement // like this: // processors[0] = (whatever the value of $processors[0] within the included file) ///////////////////////////////////////////////// echo $the_variablename[0]."[0] = ".$$the_variablename[0][0].";\n"; And what do I get for wanting total control and dynamic code?? Undefined variable. Is it because i'm accessing an array within the array? Should I be calling it as: $($the_variablename[0])[0] or $$the_variablename[0][0] or do I need to establish a separate temp variable to take care of the array value, like this: $temp = $the_variablename[0]; echo $$temp[0]; Please help!!?! Dave

« previous php.general (#107482) next »