Code: Select all
# Create array to hold all nodes
$nodeList = array();
# Create node class
class Node{
function CreateNode($assetID, $parent, $level, $children, $name, $URL){
$this->$assetID = $assetID;
$this->$parent = $parent;
$this->$level = $level;
$this->$children = $children;
$this->$name = $name;
$this->$URL = $URL;
}
}
# Populate the nodeList array
$myNode = new Node;
$nodeList[0] = $myNode->CreateNode(1,0,0,2,"Index","#");
$nodeList[1] = $myNode->CreateNode(2, 0, 1, 1, "Sub 1", "#");
$nodeList[2] = $myNode->CreateNode(3, 0, 2, 0, "Sub-Sub", "#");
$nodeList[3] = $myNode->CreateNode(4, 0, 1, 0, "Sub 2", "#");
echo $nodeList[1].assetID;assetID
I'm sure this is something easy, but I'm like brand-new to PHP so I'm at a loss of where to go from here and Googling just isn't helping, it's only gotten me here so far.