Page 1 of 1
Variable names
Posted: Thu Dec 28, 2006 9:55 am
by Citizen
I know this is a newbie question and I've tried a billion searches but....
How can I dynamically set a variable name?
For instance...
Code: Select all
$gg = "foo";
$gg.1 = "bar";
$echo "$gg1";
How can I rename variables?
Posted: Thu Dec 28, 2006 10:35 am
by dibyendrah
$gg = "foo";
$$gg = "bar"
print $foo;
Output:
Are you looking for this ?
Posted: Thu Dec 28, 2006 11:02 am
by timvw
Code: Select all
$one = "one";
${$one . "two"} = "onetwo";
echo $onetwo;
And more to be found in the manual (section about variable variables)
Posted: Thu Dec 28, 2006 12:45 pm
by daedalus__
timvw wrote:Code: Select all
$one = "one";
${$one . "two"} = "onetwo";
echo $onetwo;
That's a neat thing, I'm going to use that!
I use variable variable names a lot.