I'm trying to build a dynamic variable in PHP and despite looking at a number of the questions on the matter already here on StackOverflow I'm still stumped... :/
Variable variables is something I've never quite understood - hopefully someone here can point me in the right direction. :)
$data['query']->section[${$child['id']}]->subsection[${$grandchild['id']}]->page[${$greatgrandchild['id']}] = "Fluffy Rabbit";
Onviously the above does not work but if I hard code a variable as such:
$data['query']->section[0]->subsection[3]->page[6] = "Very Fluffy Rabbit";
...then all is fine, so obviously I'm not building my dynamic variable correctly. Any ideas?
UPDATE:
Hmm, ok I should have pointed out that these are not keys in an array - I'm addressing nodes in the XML using an ID which is specified as an attribute for each node, so the XML has the following structure:
<subtitles>
<section id="0">
<subsection id="0">
<page id="1">My content that I want to write</page>
<page id="2">My content that I want to write</page>
<page id="3">My content that I want to write</page>
</subsection>
</section>
</subtitles>
Hopefully that helps explain things a little better. :)
factory($class_name){return new $class_name()}$foo($bar)), but I'm talking about$$fooor${$foo}... Where the variables are being referenced by a name stored in another variable (the true definition of a variable-variable)...