OO Data Structures in PHP

Status
Not open for further replies.

torok

Ars Tribunus Militum
2,000
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:

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.
 
Status
Not open for further replies.