![]() |
|
|
+ Search |
![]()
|
Apr 29th, 2001 19:57
Philip Olson, Sheni R. Meledath, harry f, Nathan Wallace,
This is called "a variable variable", the manual entry is here : Variable variables : ------------------------------------------------------------ http://www.php.net/manual/en/language.variables.variable.php Essentially it works like this : $a = 'bear'; $b = 'a'; print $$b; // prints bear Essentially $$b is like $a. So : print $$b; // prints bear print ${$b}; // prints bear print $a; // prints bear Take a little time with it, it's not as complicated as it may seem. For good measure, here are a couple tutorials on the subject : http://phpbuilder.com/columns/robert20000928.php3 http://devshed.com/Server_Side/PHP/VarVar/ A tip regarding variable variables and arrays, do it like so : $var = ${$array_name}[$key];