I'm having some problems trying to define a tree structure. I've done this about a million times in Java, but I can't seem to get it to work with PHP. Here's an example of the problem in sortof psudo code:
I'm thinking php may require me to make referneces, or something of the sort, but I am not sure. Can anyone help me out? Thanks.
code:<HR>Code:$this->buildTemplate($this->root) function buildTemplate($theNode) { $dataNode = new tNode(); $dataNode->data = "The Data."; $theNode->children[] = $dataNode; // This will work: echo $theNode->children[0]->data; // But this will not, defeating the entire point: echo $this->root->children[0]->data; }
I'm thinking php may require me to make referneces, or something of the sort, but I am not sure. Can anyone help me out? Thanks.