I am trying to build a dynamic variable in PHP and, despite several questions on this issue, already here in StackOverflow, I'm still inactive ...: /
Variables are something that I never understood - I hope someone here can point me in the right direction. :)
$data['query']->section[${$child['id']}]->subsection[${$grandchild['id']}]->page[${$greatgrandchild['id']}] = "Fluffy Rabbit";
Obviously this doesn't work, but if I hardcode the variable as such:
$data['query']->section[0]->subsection[3]->page[6] = "Very Fluffy Rabbit";
... then everything is in order, so obviously I'm not building my dynamic variable correctly. Any ideas?
UPDATE:
Hmm, ok I should have indicated that these are not keys in the array - I address nodes in XML using an identifier that is listed as an attribute for each node, so 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>
Hope this helps explain the situation a bit. :)
source share